Can a nested class access its own class name as a qualified name if it is a private member of the enclosing class?
11.8.8 [class.access.nest]
Josee Lajoie

Created on 1998-10-24.00:00:00 last changed 168 months ago


Date: 2001-04-15.00:00:00

[Moved to DR at 4/01 meeting.]

Date: 2000-10-15.00:00:00

Proposed resolution (04/01):

The resolution for this issue is incorporated into the resolution for issue 45.

Date: 2004-09-10.00:00:00

Paragraph 1 says: "The members of a nested class have no special access to members of an enclosing class..."

This prevents a member of a nested class from being defined outside of its class definition. i.e. Should the following be well-formed?

    class D {
        class E {
            static E* m;

    D::E* D::E::m = 1; // ill-formed
This is because the nested class does not have access to the member E in D. 11.8 [class.access] paragraph 5 says that access to D::E is checked with member access to class E, but unfortunately that doesn't give access to D::E. 11.8 [class.access] paragraph 6 covers the access for D::E::m, but it doesn't affect the D::E access. Are there any implementations that are standard compliant that support this?

Here is another example:

    class C {
        class B
            C::B *t; //2 error, C::B is inaccessible
This causes trouble for member functions declared outside of the class member list. For example:
    class C {
        class B
            B& operator= (const B&);

    C::B& C::B::operator= (const B&) { } //3
If the return type (i.e. C::B) is access checked in the scope of class B (as implied by 11.8 [class.access] paragraph 5) as a qualified name, then the return type is an error just like referring to C::B in the member list of class B above (i.e. //2) is ill-formed.
Date User Action Args
2008-10-05 00:00:00adminsetstatus: wp -> cd1
2003-04-25 00:00:00adminsetstatus: dr -> wp
2002-05-10 00:00:00adminsetmessages: + msg681
2001-05-20 00:00:00adminsetstatus: ready -> dr
2000-11-18 00:00:00adminsetmessages: + msg400
2000-11-18 00:00:00adminsetstatus: open -> ready
1998-10-24 00:00:00admincreate