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 istream c++?

560


What methods can be overridden in java?

660


How does a C++ structure differ from a C++ class?

610


What is the latest c++ version?

600


What are the advantages of using typedef in a program?

630






Why cout is used in c++?

553


Explain the extern storage classes in c++.

541


What do you mean by const correctness?

619


Is c++ still in demand?

624


Differentiate between an external iterator and an internal iterator? What is the advantage of an external iterator.

604


Can a list of string be stored within a two dimensional array?

563


What does extern mean in a function declaration in c++?

689


Is oops and c++ same?

568


What is void pointer in c++ with example?

588


What parameter does the constructor to an ofstream object take?

600