What is a nested class? Why can it be useful?
By on May 4, 2007 in C/C++ Interview Questions
A nested class is a class enclosed within the scope of another class. For example:
// Example 1: Nested class
//
class OuterClass
{
class NestedClass
{
// …
};
// …
};
Nested classes are useful for organizing code and controlling access and dependencies. Nested classes obey access rules just like other parts of a class do; so, in Example 1, if Nested Class is [...]


