Nested or Inner Class Example in C++


Description:

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()
    {
        i.dispaly();
    }
    class Inner
    {
    public:
        void dispaly()
        {
            cout<<" Display Inner :"<<endl;
        }
    };
    Inner i;
};
int main()
{
    Outer :: Inner i;
    return 0;
}
To download raw file Click Here

Output

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


Functions


List of Programs


Pointer Examples


Memory Management Examples


Pointers and Arrays


Virtual Function Examples



Learn All in Tamil © Designed & Developed By Tutor Joes