This piece of code:

------------------------------------------------
#include <iostream>

using namespace std;

class A
{
 private: class B {public: int l;};
 public: B getB() { B b; return (b); }
};

int main()
{
        A       a;
        cout << a.getB().l;
}
------------------------------------------------

Compiles fine. The questions are:
Should the main() know that the return type of getB() contains an element named
l? - How the code in main() knows about the structure of A::B ?
Is there any difference from allowing an A::B object declared in main()?

Tested with:
g++ (GCC) 4.0.3 20051201 (prerelease) (Debian 4.0.2-5)
g++ (GCC) 3.3.5 (Debian 1:3.3.5-13)
g++ 2.95.4

Also tested with IRIX SGI CC 6.5 and C++ from Visual Studio 6.0 and it compiled
there too...

Sorry if this is not a bug.


-- 
           Summary: Allowed knowledge of private structure.
           Product: gcc
           Version: 4.0.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: v13 at it dot teithe dot gr


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25863

Reply via email to