#include<iostream.h>
#include<conio.h>
class outer
{
private:
                int n;
public:
                void read()
                                {
                                n=10;
                                }
                void display()
                                {
                                cout<<"N = "<<n<<endl;
                                }
                class inner
                {
                private:
                                int l;
                public:
                                void read()
                                                {
                                                l=20;
                                                }
                                void display()
                                                {
                                                cout<<"L = "<<l<<endl;
                                                }
                };
};
void main()
{
                outer obj1;
                outer::inner obj2;
                clrscr();
                obj1.read();
                obj1.display();
                obj2.read();
                obj2.display();
                getch();
}

158.PNG

Advertisements