Write a program to demonstrate the use of pure virtual function.
CODING:
#include<iostream.h>
#include<conio.h>
class A
{
public:
void virtual disp()=0;
};
class B:public A
{
public:
void disp()
{
cout<<"I am Class B,from DERIVED CLASS A";
}
};
void main()
{
A *a;
B b;
a=&b;
clrscr();
a->disp();
getch();
}
CODING:
#include<iostream.h>
#include<conio.h>
class A
{
public:
void virtual disp()=0;
};
class B:public A
{
public:
void disp()
{
cout<<"I am Class B,from DERIVED CLASS A";
}
};
void main()
{
A *a;
B b;
a=&b;
clrscr();
a->disp();
getch();
}
Comments
Post a Comment