Program 7:
/* Write a program in c++ for virtual function*/
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
class person
{
public :
virtual void print()
{
cout<<"\n The name of person is Bob";
}
virtual void show()
{
cout<<"\n show base"<<"\n";
}
};
class student: public person
{
public:
void print()
{
cout<<"\n The name of the student Tom";
}
};
void main()
{
clrscr();
person *p;
person p1;
*p=&p1;
[Link]();
student s1;
*p=&s1;
[Link]();
getch();
}
Output