Question:
What is a pure virtual function?
Answer:
Source: CoolInterview.com
pure virtual fn is a virtual fn which has no body.. Source: CoolInterview.com
Answered by: deepika | Date: 7/1/2008
| Contact deepika
When we declare a function with '= 0', it is called pure virtual function. The class which has declared function with '=0' can't have definition for the same. There by it is enforcing the derived classes to define the same fucntion.
virtual void fn(int) = 0; Source: CoolInterview.com
Answered by: Krishna Reddy | Date: 8/7/2008
| Contact Krishna Reddy
for exammple: class base { public: virtual void display()=0; }; the display() function is now known as a pure virtual function with no body and a "=0" in its declaration.the = sign here has got nothing to do with assignment,the value 0 is not assigned to anything.it is used to simply tell the compiler that a function will be pure,that is it will not have any body. Source: CoolInterview.com
Answered by: AMBIKA.R.BIRADAR(AIET GULBARGA) | Date: 8/21/2008
| Contact AMBIKA.R.BIRADAR(AIET GULBARGA)
Pure virtual function is the virtual functions which member functions does not have any definitions(implementation),just it equates(=) to 0. With Pure virtual function, the base class becomes "Abstract class". The abstract class does not instantiate/ create objects. But it's pointers can be assigned with Derived class objects. Source: CoolInterview.com
Answered by: Niranjan ambati | Date: 4/10/2009
| Contact Niranjan ambati
It is wrong concept that pure virtual function doesnt have body. It can have body, But it of no means bcoz u cannot create the object of abstract class.
Abstract class is a class which have atleast one pure virtual function.
The class which extends from abstract class must have to provide the definition for all pure virtual function declare in abstract class. Source: CoolInterview.com
Answered by: ko | Date: 12/9/2009
| Contact ko
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|