What is Pure Virtual Function? Why and when it is used ?
Answer Posted / ognas(shradha-asutosh)
in inheritance if the base class contains a virtual
function equating to zero, it is known also as do-nothing
function & that base class is called as abstract base class
as there are no instances or objects can be created by this
base class. And this pure virtual can be filled with the
codes in successiv derived classes accordin to the user
requirements.
The syntax of the pure virtual function is....
class class_name
{
visibility mode:\\should be protected:
virtual return_type function_name()=0;
}
new class_name : inheritance_type old class_name
{
........ //class body
........
}
| Is This Answer Correct ? | 69 Yes | 19 No |
Post New Answer View All Answers
Can you write a function similar to printf()?
If horse and bird inherit virtual public from animal, do their constructors initialize the animal constructor? If pegasus inherits from both horse and bird, how does it initialize animal’s constructor?
What does it mean to declare a destructor as static?
Are c and c++ similar?
What are the various access specifiers in c++?
What are single and multiple inheritances in c++?
Explain what happens when a pointer is deleted twice?
Explain virtual class and friend class.
Is there a sort function in c++?
How is computer programming useful in real life?
What is pure virtual function? Or what is abstract class?
Are strings mutable in c++?
What is the auto keyword good for in c++?
What is the use of seekg in c++?
What is a wchar_t in c++?