Exp21_virtualfunction
Exp21_virtualfunction
Display the data of both the read function on output screen using virtual function.*/
#include<iostream.h>
#include<conio.h>
class parent
{
public:
void virtual read()
{
cout<<"parent class read function"<<endl;
}
};
class child:public parent
{
public:
void read()
{
cout<<"child class read function"<<endl;
}
};
void main()
{
parent p,*pptr;
child c,*cptr;
clrscr();
pptr=&p;
pptr->read();
pptr=&c;
pptr->read();
getch();
}
/*OUTPUT
parent class read function
child class read function
*/