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

what is new modifier in C#

8 Answers   HCL,


what's the basic's in dot net

0 Answers   informatics,


What is a macro? And how is a macro same as a template?

4 Answers  


20% of a 6 litre solution and 60% of 4 litre solution are mixed what the % of mixture of solution it is resulted into?

5 Answers   IonIdea,


What is this interview room ? Is it a class or an object.

3 Answers   CybAge, NSN, Wipro,






i had specified the access specifier for abstarct class member like (pure virtual function) as private.But it can be accessed by the derived class.How the private member of one class is accessed by other class.if any body face this problem and found the solution plz reply to me.

1 Answers   Syntel,


What is virtual class and friend class?

5 Answers   IBS, Intel, Wipro,


What is Iteration Hierarchy? What is what is Object behavioral concept?

1 Answers  


Write A Program using Single and Multiple Inheritance.

1 Answers  


i have to create a view in SQL as like in ORACLE DATA EXPRESS EDITION

2 Answers   CTS,


Why it is called runtime polymorphism?

0 Answers  


What is a superclass in oop?

0 Answers  


Categories