What is Pure Virtual Function? Why and when it is used ?
Answer Posted / mahfuzur rahman
Virtual function vs pure virtual function :
Virtual function :-
1. Virtual function have a function body.
2. Overloaded can be done by the virtual funciton.
(Optional)
3. It is define as : virtual int myfunction();
Pure virtual function :-
1. Pure virtual function have no function body.
2. Overloading is must in pure virtual funciton. (Must)
3. It is define as : virtual int myfunction() = 0;
4. A class is "abstract class" when it has at least one
pure virtual function.
5. You cann't create instance of "abstract class", rather
you have to inherit the "abstract class" and overload all
pure virtual function.
Like :- CControlBar class is an "abstract class".
| Is This Answer Correct ? | 144 Yes | 24 No |
Post New Answer View All Answers
What is the most common mistake on c++ and oo projects?
Is c the same as c++?
Is there structure in c++?
Is c++ primer good for beginners?
What is the need of a destructor? Explain with the help of an example.
What is a node class in c++?
Explain stack & heap objects?
What is malloc in c++?
Is eclipse good for c++?
What is operator overloading in c++ example?
What is a breakpoint?
Which one between if-else and switch is more efficient?
Differentiate between an inspector and a mutator ?
Do class declarations end with a semicolon?
Write some differences between an external iterator and an internal iterator?