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


Please Help Members By Posting Answers For Below Questions

What does 7/9*9 equal ? a) 1 b) 0.08642 c) 0

594


Write my own zero-argument manipulator that should work same as hex?

593


What is meant by a delegate?

626


Write a program to find the Fibonacci series recursively.

621


How many characters are recognized by ANSI C++?

907






Describe the advantages of operator overloading?

584


What is a local reference?

683


What is the function to call to turn an ascii string into a long?

609


What is scope operator in c++?

576


write a porgram in c++ that reads an integer and print the biggest digit in the number

1780


What is c++ similar to?

612


What are put and get pointers?

593


Write a program that takes a 5 digit number and calculates 2 power that number and prints it.

2077


Why c++ is created?

590


Is c++ an integer?

588