C++ Programming - OOPS Concepts - Discussion

Discussion :: OOPS Concepts - General Questions (Q.No.44)

44. 

Which one of the following is the correct way to declare a pure virtual function?

[A]. virtual void Display(void){0};
[B]. virtual void Display = 0;
[C]. virtual void Display(void) = 0;
[D]. void Display(void) = 0;

Answer: Option C

Explanation:

No answer description available for this question.

Sudar said: (Jul 23, 2013)  
Can any one please explain me what is pure virtual functions?

Harshal said: (Aug 5, 2013)  
If any Virtual Function of the base class is equated to zero then such a function is called as a Pure Virtual Function.

Any Class which has at least one pure virtual function is called as an abstract class.

S.Priya said: (Feb 17, 2014)  
Can anyone please explain me what is the correct meaning of virtual function?

Naina said: (Jul 22, 2014)  
What does virtual function mean ?

Kirti said: (Aug 27, 2014)  
Why not option A? can anyone tell me.

Vinayak said: (Oct 8, 2014)  
A pure function is a function which does not contain implementation inside it. Pure means just declaration. Similarly,

Pure virtual functions are the function which are having virtual keyword before it and just have declaration.

And here answer is C because it must include return type and parameters type inside its declaration. That "= 0" will tell the compiler that it is a pure function so do not search for the implementation here, implementation is in the derived class.

Venu said: (Oct 21, 2016)  
What is need of pure virtual function?

Tarun said: (Dec 2, 2016)  
Why not option B is the answer?

Haritha Reddy said: (Jun 9, 2017)  
Because in option B it is just a statement it is not a function so it is not a virtual function.

Post your comments here:

Name *:

Email   : (optional)

» Your comments will be displayed only after manual approval.