An abstract class is a class that has at least one pure virtual function( A pure virtual function can have no code. ). An abstract class is just a model for all derived classes and cannot be instantiated. We can’t have an object of an abstract class because the virtual functions cannot be called. An abstract class has many uses:
- It allows polymorphism.
- It can define concrete members that can be inherited in derived classes and that do not have to be redefined.
- It provides a model for the pure virtual functions that must be redefined in the derived class.
An abstract class combines the idea of inheritance, polymorphism, and modeling.
The post what is an Abstract class appeared first on Programming Baba.