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 insertion operator and what does it do?
What are c++ tokens?
What are the different types of polymorphism in c++?
Is it possible for a member function to use delete this?
What is prototype for that c string function?
What is the disadvantage of using a macro?
Can a list of string be stored within a two dimensional array?
What are containers in c++?
Explain differences between alloc() and free()?
What is the use of volatile variable?
What is a stack? How it can be implemented?
What is heap sort in c++?
What are proxy objects in c++?
What are separators in c++?
Explain how we implement exception handling in c++?