In one of the famous book called Thinking in C++, in one of the example Bruce Eckel made nested class as friend like,
I used above code without using friend to nested class and worked correctly. So what should be the conclusion, does nested class should be declared as friend for accessing private data of outer class or it can directly access it without friend
A nice question in this section after long time.
Pranit, Bruce Eckel gave this statement as it is true based on the 1998 C++ draft. Now if you are using any compiler say MSVC 6.0 then you will get error if you haven't made your nested class friend class.
However a latter draft corrected this and stated that
"A nested class is a member and as such has the same access rights as any other member",
so if you use any compiler shipped with this modification then the use of 'friend' is no longer needed
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)