Abstract Base Class
Abstract Base Class (ABC)
Classes that act as base classes and not meant to be instantiated are called abstract base classes.
Properties possessed by abstract base class(ABC) are:
• An ABC should contain at least one pure virtual function.
• An ABC has no instances (objects).
• An ABC should omit implementations except for the destructor and functions that provide access to private data members. That means, virtual functions in an abstract base class usually should be pure.
• An ABC is used only as the basis for derived classes and thus defines a minimum interface for its descendants.
Example of an ABC is:
class ABC
{
public:
virtual void purevirtualfunction() = 0;
};
Above is an abstract base class. This class is inherited by the other classes, like
class hello : public ABC
{
public:
void purevirtualfunction()
{
……………
//methods and variables
……………
}
};
Posted in Computer Science, Information Technology, Object Oriented Programming, Object Oriented Programming |
