Abstract Class in C++

In a C++ programming language , a class that contains at least one pure virtual function is called  abstract class.

This  pure virtual function is a function is declared within base class and defined by derived class.

Like a other class abstract class can also contains normal function.

We can not create object of an abstract class,Any attempt to so will result in an error, but we can create reference to an abstract class.  


Description: In the above program, we have declared a pure virtual function “show()” in a base class A which is defined by derived class B. 

Because class A contain a pure virtual function therefore class A is an abstract class.  

Abstract class can also contain a normal member   function (in this program member function is display() ).

Categories C++