#include<iostream.h>
#include<conio.h>
class demo
{
                int x;
                void display()
                                {
                                cout<<"X = "<<x<<endl;
                                cout<<"Y = "<<y<<endl;
                                cout<<"Z = "<<z<<endl;
                                }
protected:
                int y;
                void access()
                                {
                                x=10;
                                y=20;
                                z=30;
                                display();
                                }
public:
                int z;
                void read()
                                {
                                access();
                                }
};
void main()
{
                demo v;
                clrscr();
                v.read();
                getch();
}

142.PNG

Advertisements