Abstract Classes
Abstract classes are the classes, which are written just to act as base classes. Consider the following classes.
class base
{
:
:
};
class Aclass : public base
{
:
:
};
class Bclass : public base
{
:
:
};
class Cclass : public base
{
:
:
};
void main()
{
Aclass objA;
Bclass objB;
Cclass objC;
:
:
}
There are three classes - Aclass, Bclass, Cclass - each of which is derived from the class base. The main () function declares three objects of each of these three classes. Though, it does not declare any object of the class base. This class is a general class whose sole purpose is to serve as a base class for the other three. Classes used only for the purpose of deriving other classes from them are known as abstract classes. They simply serve as base class, and no objects for such classes are created