   [C++] Nested classes
  Can a nested C++ class access private/protected members of its enclosing parent class, or vice versa?I recall that this is legal in C# - a nested class has full access to the internals of its enclosing class. But I don't remember what the C++ standard says about this, and I've seen some conflicting information.So what's the verdict?   
Quote:Nested classes can directly use names, type names, names of static members, and enumerators only from the enclosing class. To use names of other class members, you must use pointers, references, or object names.Source: http://msdn.microsoft.com/en-us/library/x23h0937(VS.80).aspx;  IIRC there are a few compilers which essentially make a nested class a friend of its enclosing class, but that's not standard.   ;Quote:Original post by swiftcoderQuote:Nested classes can directly use names, type names, names of static members, and enumerators only from the enclosing class. To use names of other class members, you must use pointers, references, or object names.Source: http://msdn.microsoft.com/en-us/library/x23h0937(VS.80).aspxWhat I had in mind was more to do with public/protected/private access. That is, given a pointer to its enclosing class, can a member function in a nested class access private members of its enclosing class?   ;Quote:Original post by Sc4Freakgiven a pointer to its enclosing class, can a member function in a nested class access private members of its enclosing class?Just try it:class X{    int x;public:    class Y    {   int y;    public:   Y(X const& ref) : y(ref.x) {}    };};int main(){    X a;    X::Y b(a);}