<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[[gelöst] [C++03] - Zugriffsrechte einer Nested Class]]></title><description><![CDATA[<p>Hi Forum,</p>
<p>ich habe mal eine Frage zu Code, der mich jetzt doch ziemlich überrascht hat:</p>
<pre><code class="language-cpp">class A
{
public:
  A() : _x(20) {}

  class X {
  public:
    int f(A* a) {
      return a-&gt;_x;
    }
  };

private:
  int _x;
};
</code></pre>
<p>Warum darf hier A::X::f auf private member von A zugreifen? Zumindest fressen g++, comeau (online tryitout) und clang das.</p>
<p>Ich habe mal im Standard gewühlt zu nested classes und member access control, aber der richtige Absatz wollte sich mir nicht zeigen. Im Gegenteil legt 11.8 &quot;The members of a nested class have no special access to members of an enclosing class […]&quot; mir irgendwie das Gegenteil nahe. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
<p>Kann mich mal jemand bitte mit dem entsprechenden Paragraphen aufschlauen?</p>
<p>Danke &amp; Gruß <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/topic/311067/gelöst-c-03-zugriffsrechte-einer-nested-class</link><generator>RSS for Node</generator><lastBuildDate>Tue, 04 Aug 2026 00:33:00 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/311067.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 26 Nov 2012 07:55:18 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [gelöst] [C++03] - Zugriffsrechte einer Nested Class on Mon, 26 Nov 2012 13:38:02 GMT]]></title><description><![CDATA[<p>Hi Forum,</p>
<p>ich habe mal eine Frage zu Code, der mich jetzt doch ziemlich überrascht hat:</p>
<pre><code class="language-cpp">class A
{
public:
  A() : _x(20) {}

  class X {
  public:
    int f(A* a) {
      return a-&gt;_x;
    }
  };

private:
  int _x;
};
</code></pre>
<p>Warum darf hier A::X::f auf private member von A zugreifen? Zumindest fressen g++, comeau (online tryitout) und clang das.</p>
<p>Ich habe mal im Standard gewühlt zu nested classes und member access control, aber der richtige Absatz wollte sich mir nicht zeigen. Im Gegenteil legt 11.8 &quot;The members of a nested class have no special access to members of an enclosing class […]&quot; mir irgendwie das Gegenteil nahe. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
<p>Kann mich mal jemand bitte mit dem entsprechenden Paragraphen aufschlauen?</p>
<p>Danke &amp; Gruß <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2274690</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2274690</guid><dc:creator><![CDATA[7H3 N4C3R]]></dc:creator><pubDate>Mon, 26 Nov 2012 13:38:02 GMT</pubDate></item><item><title><![CDATA[Reply to [gelöst] [C++03] - Zugriffsrechte einer Nested Class on Mon, 26 Nov 2012 08:04:27 GMT]]></title><description><![CDATA[<p>Laut Standard ist das in Ordnung.<br />
Ist mMn auch sinnvoll.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2274692</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2274692</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Mon, 26 Nov 2012 08:04:27 GMT</pubDate></item><item><title><![CDATA[Reply to [gelöst] [C++03] - Zugriffsrechte einer Nested Class on Mon, 26 Nov 2012 08:26:13 GMT]]></title><description><![CDATA[<p>Hmm...in der Tat sollte das nicht funktionieren, wenn ich mir den alten Standard anschaue.<br />
Evtl. ist das allerdings auch ein (offensichtlicher) Fehler im Standard und wurde deswegen von den Compilerherstellern nicht implementiert?!</p>
<p>In C++11 wurde die entsprechende Stelle geändert...</p>
<p>Siehe hier: <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3337.pdf" rel="nofollow">http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3337.pdf</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2274695</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2274695</guid><dc:creator><![CDATA[Furble Wurble]]></dc:creator><pubDate>Mon, 26 Nov 2012 08:26:13 GMT</pubDate></item><item><title><![CDATA[Reply to [gelöst] [C++03] - Zugriffsrechte einer Nested Class on Mon, 26 Nov 2012 08:47:40 GMT]]></title><description><![CDATA[<p>Stimmt, in den 11er hatte ich noch nicht geschaut, danke für die Antwort.</p>
<p>Zumindest ist es schonmal gut zu wissen, dass ich dann doch nicht zu blöd zum Lesen war. Das Code-Beispiel im 2003er sagt ja auch explizit &quot;Error&quot; dazu.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2274699</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2274699</guid><dc:creator><![CDATA[7H3 N4C3R]]></dc:creator><pubDate>Mon, 26 Nov 2012 08:47:40 GMT</pubDate></item><item><title><![CDATA[Reply to [gelöst] [C++03] - Zugriffsrechte einer Nested Class on Mon, 26 Nov 2012 16:27:16 GMT]]></title><description><![CDATA[<p>Hehe, tut mir Leid! Ich dachte, das müsse doch in beiden Standards gleich sein und habe nur in den N3337-er geguckt. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2274843</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2274843</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Mon, 26 Nov 2012 16:27:16 GMT</pubDate></item></channel></rss>