Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) Abstract base class

 

An abstract base class is a type of base class that can not be instanciated itself, only its derivatived classes can.

 

Abstract base class is abbreviated as ABC.

 

An ABC can be recognized by a method starting with the keyword virtual and ending with =0; . And because all base classes must have a virtual destructor, an ABC must also have one.

 

struct ABC
{
  virtual ~ABC() {} //Empty virtual destructor
  virtual void whatMakesMeAbstract() = 0;
};

 

Many Design Patterns rely on an ABC, for example the Strategy.

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict