### Abstract Classes

An abstract class is a class that is designed to be specifically used as a base class. An abstract class contains at least one pure virtual function. Pure virtual functions are inherited. You can declare a function to be pure by using a pure specifier in the declaration of the member function in the class declaration.

For example:

    class AB             // abstract class
    {
    public:
          virtual void f()= 0; // pure virtual member function
    };

A function that is declared pure typically has no definition and cannot be executed. Attempting to call a pure virtual function that has no implementation is undefined; however, such a call does not cause an error. No objects of an abstract class can be created.

Note: Because destructors are not inherited, a virtual destructor that is declared pure must have a definition.

Virtual member functions are inherited. If a base class contains a pure virtual member function and a class derived from that base class does not redefine that pure virtual member function, the derived class itself is an abstract class. Any attempt to create an object of the derived class type produces an error.

You cannot use an abstract class as the type of an explicit conversion, as an argument type, or as the return type for a function. You can declare a a pointer or reference to an abstract class.

Inheritance Overview

Examples of Errors using Abstract Classes

Virtual Functions
Derivation