/************************************************************************ *
The following example shows an attempt to create an object of an abstract
class type.
* ************************************************************************/
class AB // abstract class
{
public:
virtual void f()= 0; // pure virtual member function
};
class D: public AB
{
public:
void f();
};
// ...
void main ()
{
D d;
d.f() ; // calls D::f()
AB ab; // error, cannot create an object of an
// abstract class type
}
/************************************************************************ *
The following example shows an attempt to create an object of a class
derived from an abstract class, but that does not redefine the pure
virtual function of that abstract class.
* ************************************************************************/
For example:
class AB // abstract class
{
public:
virtual void f()= 0; // pure virtual member function
};
class D2: public AB
{
int a,b,c;
public:
void g();
};
// ...
void main ()
{
D2 d;
// error, cannot declare an object of abstract class D2
}
To avoid the error in the above example, provide a declaration of D2
::f().