13.7 ABSTRACT CLASSES

Object-oriented programming languages define classes so that objects can be declared as those of classes. However, because of inheritance we may be defining some classes such that they serve as base class only. We as programmers are not interested in defining any object of these classes. Such classes are termed as abstract classes. A class, in which a pure virtual function appears, becomes an abstract class. Normally, such a class is used as base class. Therefore, it may also be referred as an abstract base class. We cannot declare objects of this class. The compiler will not allow us to do so.

When a base class has a pure virtual function, every class derived from such base class should redefine this function. Otherwise, ...

Get Object Oriented Programming with C++, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.