1

Possible Duplicates:
nested classes C++
nested class access control in C++

I'm a little confused as to what access a nested class has to the members of an enclosing class. What is the relationship it shares with the outer class?

Community
  • 1
  • 1
rubixibuc
  • 7,111
  • 18
  • 59
  • 98

2 Answers2

2

The nested class does not have any special access to the enclosing class that would not be available to any other class - it can see public members, etc. The nesting only provides a useful scoping mechanism for nested class, but doesn't change its behavior or capabilities.

jwismar
  • 12,164
  • 3
  • 32
  • 44
  • What about typenames such as vector>int<::iterator, can the iterator class use typename int to type objects inside it's class? I revered the >< because it hides them. – rubixibuc Apr 29 '11 at 03:57
  • In the general case, no, the nested class wouldn't have special information. In the specific case of vector's iterator class, that class is actually a class template instance that takes the same type parameter as the container class. It's also the case, though, that vector has a value_type typedef of it's type parameter, and that's often used in generic programming. – jwismar Apr 29 '11 at 05:17
  • @rubixibuc: To format code, put it in backticks: `\`vector::iterator\`` – MSalters Apr 29 '11 at 07:36
1

This might help you : nested class access control in C++. It is not exacly what you asked, but gives some interesting informations.

Community
  • 1
  • 1
Drahakar
  • 5,986
  • 6
  • 43
  • 58