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 guid? Why does com need guids?
How can you tell what shell you are running on unix system?
What are advantages of using friend classes?
How compile and run c++ program in turbo c++?
What is command line arguments in C++? What are its uses? Where we have to use this?
What are protected members in c++?
What does flush do c++?
What are the vectors in c++?
What is endianness?
What data structure is fastest, on average, for retrieving data: a) Binary Tree b) Hash Table c) Stack
Is c++ vector a linked list?
What is searching?
What do you mean by translation unit?
Refer to a name of class or function that is defined within a namespace?
Which one is better- macro or function?