Pure virtual function are the functions which does not have function body. The pure virtual function present within any class, called as abstract class.
Syntax: virtual return_type function_name(parameter_list)=0;e.g
virtual void show()=0;It treated as abstract class.
#include<conio.h> #include<iostream.h> class Number{ protected: int num; public: void set(int n){ num=n; } virtual void show()=0; }; class Hexa:public Number{ public: void show(){ cout<<"\n Hexadecimal "<<hex<<num; } }; class Octal:public Number{ public: void show(){ cout<<"\n Octal "<<oct<<num; } }; class Decimal:public Number{ public: void show(){ cout<<"\n Decimal "<<dec<<num; } }; void main() { clrscr(); Hexa h; Octal o; Decimal d; h.set(11); o.set(8); d.set(12); h.show(); o.show(); d.show(); getch(); }O/P
Hexadecimal b Octal 10 Decimal 12