i need to add virtual function to my coding. somebody please help. whre should i put it
heres the code.
figure.h
//This is the header file figure.h.
using std::cout;
class figure
{
public:
virtual void center();
void draw();
void erase();
};
void figure::center()
{
cout << "Centering the Figure";
cout << "\n";
cout << "\n";
rectangle.h
//This is the header file rectangle.h.
using std::cout;
class rectangle : public figure
{
public : void erase();
l void draw();
};
void rectangle::draw()
{
cout << "Drawing rectangle";
}
void rectangle::erase()
{
cout << "Erasing rectangle";
}
triangle.h
//This is the header file triangle.h.
using std::cout;
class triangle : public figure
{
public : void erase();
void draw();
};
void triangle::draw()
{
cout << "Drawing triangle";
}
void triangle::erase()
{
cout << "Erasing triangle";
}
virtual.cpp
//This is the header file triangle.h.
using std::cout;
class triangle : public figure
{
public : virtual void erase();
virtual void draw();
};
void triangle::draw()
{
cout << "Drawing triangle";
}
void triangle::erase()
{
cout << "Erasing triangle";
}
please help me. asap. thankx in advance