/*PROGRAM TO IMPLEMENT THE CONCEPT OF VIRTUAL FUNCTIONS*/
#include<conio.h>
#include<iostream.h>
class A
{
public:
virtual void display()
{
cout<<“Base class A’s display() function is executed”<<endl;
}
};
class B:public A
{
public:
void display()
{
cout<<“Derived class B’s display() function is executed”<<endl;
}
};
class C:public A
{
public:
void display()
{
cout<<“Derived class C’s display() function is executed”<<endl;
}
};
void main()
{
A *ptr,a1;
B b1;
C c1;
clrscr();
ptr=&a1;
a1.display();
ptr=&b1;
ptr->display();
ptr=&c1;
ptr->display();
getch();
};