A nested class is a class which is declared in another enclosing class. A nested class is a member and as such has the same access rights as any other member. The members of an enclosing class have no special access to members of a nested class; the usual access rules shall be obeyed.
For example, program 1 compiles without any error and program 2 fails in compilation.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Nested list in C++ STL
- Can namespaces be nested in C++?
- C++ | Nested Ternary Operator
- Nested Loops in C++ with Examples
- Nested switch statement in C++
- Decision Making in C / C++ (if , if..else, Nested if, if-else-if )
- C++ Classes and Objects
- Trivial classes in C++
- Anonymous classes in C++
- Local Classes in C++
- Storage Classes in C++ with Examples
- File Handling through C++ Classes
- C++ Stream Classes Structure
- Mutual friendship of Classes in C++ with Examples
- How to add reference of an object in Container Classes
- Virtual functions in derived classes
- Catching base and derived classes as exceptions
- Pure Virtual Functions and Abstract Classes in C++
- Enum Classes in C++ and Their Advantage over Enum DataType
Improved By : Akshit Agarwal 3