What is a 'pure' virtual function and what's its use?

Answer Posted / phool chand

A pure virtual function is signified by using `=0;' in place of the body of the function. The presence of a pure virtual function prevents instantiation of the class which contains it. For this to be of any use, a derived class must implement the pure virtual function. I.e. the derived class must provide a function with the same name which includes a function body.

The basic reason for pure virtual functions is to specify something that a class can do without specifying how the class will do it.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is data structure in c++?

663


Difference between Abstraction and encapsulation in C++?

580


What is abstract keyword in c++?

593


What is the best it certification?

586


What is functions syntax in c++?

623






Is vector a class in c++?

596


What do you mean by translation unit?

605


What are the differences between the function prototype and the function defi-nition?

623


What is meant by forward referencing and when should it be used?

560


Does c++ have string data type?

691


How the endl and setw manipulator works?

560


How many types of modularization are there in c++?

566


What is encapsulation in c++?

674


How do you save a c++ program?

559


What is a string example?

551