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 size of string in c++?
Write a program using display() function which takes two arguments.
Is swift faster than go?
Explain about vectors in c ++?
What operator is used to access a struct through a pointer a) >> b) -> c) *
Explain container class.
How do you invoke a base member function from a derived class in which you have not overridden that function?
What are destructors?
What is flush () in c++?
What do you mean by “this” pointer?
What is the difference between while and do while loop?
What is binary object model?
What is the use of bit fields in structure declaration?
Do you need a main function in c++?
Which software is best for programming?