#include<iostream.h>
#include<conio.h>
class base
{
private:
int a;
public:
class nested
{
private:
int b;
public:
void getdatan(int y)
{
b=y;
}
void displayn()
{
cout<<"\n nested value is="<<b;
}
} n;
void getdata(int x)
{
a=x;
}
void display()
{
cout<<"\n Base Value is="<<a;
}
} ;
main()
{
clrscr();
base b1;
b1.getdata(5);
b1.display();
b1.n.getdatan(7);
b1.n.displayn();
getch();
}
-----------------------------------------------------------------------------------------------------
A nested class is declared within the scope of another class. The name of a nested class is local to its enclosing class. Unless you use explicit pointers, references, or object names, declarations in a nested class can only use visible constructs, including type names, static members, and enumerators from the enclosing class and global variables.
Member functions of a nested class follow regular access rules and have no special access privileges to members of their enclosing classes. Member functions of the enclosing class have no special access to members of a nested class.
VIEW SOURCE :-- http://publib.boulder.ibm.com/infocenter/lnxpcomp/v8v101/index.jsp?topic=/com.ibm.xlcpp8l.doc/language/ref/cplr061.htm