Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is this polymorphism, encapsulation or what??

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0

Please advise what this represents??
Is it polymorphism,encapsulation,default constructor stuff.

I need to know some of the names to describe this program that works.

[tt]
class Data
{
private:
int x;
protected:
int y;
public:
int z;
Data(int x=0,int y=0,int z=0);
void ShowX();
void ShowY();
void ShowZ();

virtual void All();
};
void Data::ShowX()
{
cout << x << endl;
}
void Data::ShowY()
{
cout << y << endl;
}
void Data::ShowZ()
{
cout << z << endl;
}
void Data::All()
{
cout << x << &quot;\n&quot; << y << &quot;\n&quot; << z << endl;
}
Data::Data(int x,int y,int z)
{
Data::x=x;
Data::y=y;
Data::z=z;
All();
}
class Lower:public Data
{
public:
int d;
void ShowD();
Lower(int,int,int,int);
void All();
};
void Lower::ShowD()
{
cout << d << endl;
}
void Lower::All()
{
Data::All();
cout << d << endl;
}
Lower::Lower(int x,int y,int z,int d):Data(x,y,z)
{
d=d;
Data::All();
cout << d << endl;
}
void main()
{
Lower s1(5,4,56,7);
}[/tt]
 
This is plain old inheritance.

William
Software Engineer
ICQ No. 56047340
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top