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
What is lazy initialization in c++?
What is the use of "new" operator?
What are the uses of pointers?
I was a c++ code and was asked to find out the bug in that. The bug was that he declared an object locally in a function and tried to return the pointer to that object. Since the object is local to the function, it no more exists after returning from the function. The pointer, therefore, is invalid outside.
Explain how functions are classified in C++ ?
Describe the advantages of operator overloading?
How would you use the functions memcpy(), memset(), memmove()?
Is there a c++ certification?
What is an accessor in c++?
What do you mean by a template?
What is c++ and its features?
How do you decide which integer type to use?
What is ofstream c++?
Why do we use using namespace std in c++?
Write syntax to define friend functions in C++.