cpp/language/abstract class

Defines an abstract type which cannot be instantiated, but can be used as a base class.

Syntax
A pure virtual function is a whose  has the following syntax:

Here the sequence is known as, and appears either immediately after the  or after the optional  ( or ).

cannot appear in a member function definition or declaration.

An abstract class is a class that either defines or inherits at least one function for which is pure virtual.

Explanation
Abstract classes are used to represent general concepts (for example, Shape, Animal), which can be used as base classes for concrete classes (for example, Circle, Dog).

No objects of an abstract class can be created (except for base subobjects of a class derived from it) and no non-static data members whose type is an abstract class can be declared.

Abstract types cannot be used as parameter types, as function return types, or as the type of an explicit conversion (note this is checked at the point of definition and function call, since at the point of function declaration parameter and return type may be incomplete).

Pointers and references to an abstract class can be declared.

The definition of a pure virtual function may be provided (and must be provided if the pure virtual is the ): the member functions of the derived class are free to call the abstract base's pure virtual function using qualified function id. This definition must be provided outside of the class body (the syntax of a function declaration doesn't allow both the pure specifier and a function body).

Making a virtual call to a pure virtual function from a constructor or the destructor of the abstract class is undefined behavior (regardless of whether it has a definition or not).