Why do we use virtual functions?

Answers were Sorted based on User's Feedback



Why do we use virtual functions?..

Answer / uma sankar pradhan

we use virtual functions to achive dynamic binding
Dynamic binding is establishing relation between the
function call and function definition at run time

Is This Answer Correct ?    22 Yes 2 No

Why do we use virtual functions?..

Answer / bijal

The virtual function can be allowed in base classes only.
The functions markd Virtual will only be overridable in
derieved classes.
If i m having a function in base class that shud come in
derieved class but i want it to have different behaviour.
This can only be acheived only if base class function is
virtual function.

Is This Answer Correct ?    23 Yes 8 No

Why do we use virtual functions?..

Answer / td

A pure virtual member function is a member function that the
base class forces derived classes to
provide. Normally these member functions have no
implementation. Pure virtual functions are
equated to zero.
class Shape { public: virtual void draw() = 0; };

Is This Answer Correct ?    8 Yes 4 No

Why do we use virtual functions?..

Answer / mona kawale

when there are two same classes in derived and base class then at the tym of running programm compiler get confuse about which function should b call first so it call derived class function automatically....but if we wrote base class function as virtual function then compiler will not get confuse.....

Is This Answer Correct ?    2 Yes 0 No

Post New Answer

More OOPS Interview Questions

function overridind means and simple program

2 Answers  


What is Dynamic Polymorphism?

13 Answers  


What is the difference between and interface and an abstract class ?

4 Answers   IBM, Infosys, Ness Technologies,


There are 2 empty jars of 5 and 3 liters capacity. And a river is flowing besides. I want to measure 4 liters of wanter using these 2 jars. How do you do this?

4 Answers  


what is the difference between function template and template of function?explain with example.

2 Answers  


What is the different between Applet and Application?

2 Answers  


What is coupling in oop?

0 Answers  


Round up a Decimal number in c++.. example Note = 3.5 is as 4 3.3 is as 3

3 Answers   Accenture, Cognizant, IBM,


WILL I GET A guaranteed JOB AFTER DOING bsc()IT) and GNIIT from an NIIT CENTRE??

21 Answers   Biocon, MIT, NIIT,


What causes polymorphism?

0 Answers  


can you give real time example for polymarphism

5 Answers   TCS,


What is the difference between static polymorphism and dynamic polymorphism?

0 Answers  


Categories