You can't. Once you define an abstract base class, you need to implement all the functions in it's descendants. Otherwise the compiler won't know what you want to do. Imagine:
class Person
{
public:
virtual void beCustomer() = 0;
virtual void doSales() = 0;
};
class Customer : public Person
{
public:
virtual void beCustomer() { doStuff(); }
}
With this code:
Person* p;
p = new Customer();
p.doSales();
Now, p.doSales();
is a perfectly valid call, because you promised that any Person
has a doSales()
method right?
The only solution is to use empty methods instead of abstract ones:
class Person
{
public:
virtual void beCustomer() {};
virtual void doSales() {};
};