Write a program to show the concept of abstract class.+(short notes of pure virtual function)

Pure virtual function and abstract base class


A virtual function of the for-:

Virtual return_type function_name()=0 is said to be pure virtual function.

Pure virtual function do not contain body. Here 0 after assignment operator indicates that the virtual function is pure.


Abstract class-:

Class having at least 1 pure virtual function is said to be abstract class.

The normal object of an abstract class can’t be created; only pointer object of the abstract class can be created.


Remember this-: normal object of an abstract class(class having 1 pure virtual function) can’t be created but a pointer object can be created.


The pure virtual function should be overridden in each derived classes because due to inheritance feature, if your pure virtual function is not overridden in each derived classes, then derived class also becomes as an abstract class due to which normal object of different derived classes can’t be created.


Normal objects of different derived classes can’t be created so we need to override pure virtual function in each derived classes.



An example program to show the concept of abstract class.


the area of rectangle=35.75
area of triangle=31.875

Leave a Comment

Your email address will not be published. Required fields are marked *

Do NOT follow this link or you will be banned from the site! Scroll to Top