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 c++ w3school?
Write about the scope resolution operator?
Which compiler does turbo c++ use?
Can we use this pointer inside static member function?
True or false, if you keep incrementing a variable, it will become negative a) True b) False c) It depends
What does override mean in c++?
Define namespace in c++?
Why struct is used in c++?
Is it legal in c++ to overload operator++ so that it decrements a value in your class?
What is difference between class and function?
What is the oldest programming language?
Write a program which uses functions like strcmp(), strcpy()? etc
Should you pass exceptions by value or by reference?
Explain dangling pointer.
Are php strings immutable?