Write a program of pure virtual function


 

/* Write a program of  pure virtual function*/

#include<iostream.h>

#include<conio.h>

class a

{

public:

virtual void dis()=0;

};

class b:public a

{

public:

void dis()

{

cout<<“hello”<<endl;

}

};

class c:public a

{

public:

void dis()

{

cout<<“bye”<<endl;

}

};

void main()

{

clrscr();

class b b1;

class c c1;

b1.dis();

c1.dis();

getch();

}

/* output:

hello

bye

hello

bye*/

Related Posts

Comments are closed.