What is Pure virtual Function ?

Pure virtual function is a Member function of the class which is not implemented into the base class even though it is implemented in all its derived class. It is representing by writing keyboard virtual at the beginning and equal to zero it doesn’t have any function body. Class in which pure virtual function is defined is called abstract class and it’s not possible to create an object of abstract class. It means class cannot be instantiated.

Suppose we are having a class shape and there is a Member function of that class is draw () the it’s not possible to define this function in to the base class itself because there may be shape of triangle there may be safe of rectangle there there may be shape of circle and every class has its own method of draw  so we make this function as pure virtual function into the base class and will implement into each and every derived class according to the particular class requirement.

2,261 total views, 5 views today

Leave a Reply