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 are the two types of polymorphism?
Why do we use using namespace std in c++?
Why is standard template library used?
Explain the scope of resolution operator.
Define namespace in c++?
Does c++ have string data type?
How do you establish an is-a relationship?
How do c++ struct differs from the c++ class?
What are static type checking?
What is ifstream c++?
Define pure virtual function?
What is purpose of abstract class?
How should a contructor handle a failure?
How can I learn c++ easily?
What is the two main roles of operating system?