Write a program of hierarchical inheritance


 

/* Write a program of hierarchical inheritance*/

#include<iostream.h>

#include<conio.h>

class a

{

public:

void dis()

{

cout<<“dis”<<endl;

}

};

class b:public a

{

public:

void show()

{

cout<<“show”<<endl;

}

};

class c:public b

{

public:

void print()

{

cout<<“print”<<endl;

}

};

void main()

{

clrscr();

class b b1;

class c c1;

b1.dis();

b1.show();

c1.dis();

c1.print();

getch();

}

/* output:

dis

show

dis

print*/

Related Posts

Comments are closed.