1 Answers
- A virtual function is declared inside the base class and it is redefined in the derived classes.
- The function inside the base class serves as a placeholder as it has no definition relative to the base class.
- Such functions are called “do-nothing” function
- virtual void display() = 0;
- Such functions are called pure virtual functions.
- A class containing pure virtual functions cannot be used to declare any objects of its own, such classes are called abstract base classes.
- The main objective of an abstract base class is to provide some traits to the derived classes and to create a base pointer required for achieving run time polymorphism.