Monday, March 22, 2010

C++ example for pure virtual function

#include
#include
class number
{
protected:
int value;
public:
virtual void show()=0;//pure virtual func:
void setvalue(int v){ value=v; }
};

class hexa:public number
{
public:
void show()
{
cout<<"the hexadecimal number is "<<<
}
};

class octal:public number
{
public:
void show()
{
cout<<"the octal number is "<< oct<<
}
};

void main()
{
clrscr();
octal o;
hexa h;
h.setvalue(15);
h.show();
o.setvalue(10);
o.show();
}