Nested or Inner Class Example in C++


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.

Example Program:

Here is the simple program nested or inner class in C++.

Source Code

#include<iostream> //Doubt
using namespace std;
class Outer
public :
    void fun()
    class Inner
        void dispaly()
            cout<<" Display Inner :"<<endl;
    Inner i;
int main()
    Outer :: Inner i;
    return 0;
To download raw file Click Here


Display Inner

Basic Programs

Flow Control

IF Statement Examples

Switch Case

Goto Statement

Break and Continue

While Loop

Do While Loop

For Loop

Friend Function in C++

String Examples

Array Examples

Structure Examples

Structure & Pointer Examples

Structure & Functions Examples

Enumeration Examples

Template Examples


Inheritance Examples

Hierarchical Inheritance

Hybrid Inheritance

Multilevel Inheritance

Multiple Inheritance

Single Level Inheritance

Class and Objects

Constructor Example

Destructor Example

Operator Overloading Example

Operator and Function Example

List of Programs

Pointer Examples

Memory Management Examples

Pointers and Arrays

Virtual Function Examples

Learn All in Tamil © Designed & Developed By Tutor Joes