//Use of Virtual Keyword in CPP
#include<iostream.h>
#include<conio.h>
class A
{
protected:
int a;
};
class B:public virtual A
{
protected:
int b;
};
class C:public virtual A
{
protected:
int c;
};
class D:public virtual A
{
protected:
int d;
};
class E:public virtual B,public virtual C
{
protected:
int e;
};
class F:public virtual C,public virtual D
{
protected:
int f;
};
class G:public E,F
{
private:
int g;
public:
void getdata()
{
cout<<"Enter 7 values\n";
cin>>a>>b>>c>>d>>e>>f>>g;
}
void showdata()
{
cout<<"\nFirst value="<<a;
cout<<"\nSecond value="<<b;
cout<<"\nThird value="<<c;
cout<<"\nFourth value="<<d;
cout<<"\nFifth value="<<e;
cout<<"\nSixth value="<<f;
cout<<"\nseventh value="<<g;
}
};
void main()
{
clrscr();
G x;
x.getdata();
x.showdata();
getch();
}
No comments:
Post a Comment
Note: only a member of this blog may post a comment.