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
Where Malloc(), Calloc(), and realloc() does get memory?
What flag means?
Which software is used to run c++ program?
What is a lambda function c++?
What are the two types of comments, and how do they differ?
What is an associative container in c++?
Difference between overloading vs. Overriding
What is the difference between interpreters and compilers?
Explain about Garbage Collector?
A mXn matrix is given and rows and column are sorted as shown below.Write a function that search a desired entered no in the matrix .with minimum complexity 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Can a class be static in c++?
Do you know what are pure virtual functions?
Is it possible for a member function to delete the pointer, named this?
What is == in programming?
How many ways can a variable be initialized into in C++?