What is Pure Virtual Function? Why and when it is used ?

Answer Posted / shakti singh

A virtual function in a base class which is equated to 0 is called a pure virtual function.The class then is called a Abstract Base Class or in general ABC.No object of such class can be instantiated.ABC in general acts as an interface and implement the general flow of algorithm.A pure virtual function must be overloaded in the derived class otherwise the compiler will throw an error.
A pure virtual function do nothing and it is not concerned with the implementation detail.

Is This Answer Correct ?    13 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

find the two largest values among the 6 numbers using control structures : do-while,for,if else,nestedif- else ,while. one or two of them.

2005


What is a virtual destructor? Explain the use of it?

553


Do you know what are static and dynamic type checking?

626


Is c++ still in demand?

641


What is the use of main function in c++?

536






How would you use the functions randomize() and random()?

635


Explain the volatile and mutable keywords.

619


What information can an exception contain?

671


Define the operators that can be used with a pointer.

583


How much do coding jobs pay?

557


What is the use of structure in c++?

562


What is the real purpose of class – to export data?

622


Explain the scope of resolution operator.

635


How to give an alternate name to a namespace?

597


What is the difference between global int and static int declaration?

416