what is virtual function?

Answers were Sorted based on User's Feedback



what is virtual function?..

Answer / kumod

virtual function can be used to override the propertis of a
function.it is normaly used in inheritance. it is part of
polymerphism.

Is This Answer Correct ?    180 Yes 18 No

what is virtual function?..

Answer / jayakrishna reddy

The virtual keyword means that method,property or function
can be overridden

Is This Answer Correct ?    154 Yes 24 No

what is virtual function?..

Answer / manab

When derived class overrides the base class method by
redefining the same function, then if client wants to
access redefined the method from derived class through a
pointer from base class object, then you must define this
function in base class as virtual function.

Is This Answer Correct ?    68 Yes 7 No

what is virtual function?..

Answer / manav sharma

It allows one to write generalized code that works with the
base class pointer which can dynamically point to the
derieved class objects. Virtual function allows you to
implement runtime polymorphism. It allows the function call
to be binded with function definition as late as runtime.

Also read: concept of VPTR and VTABLE from Thinking in C++

Is This Answer Correct ?    56 Yes 8 No

what is virtual function?..

Answer / aarti ashar

A virtual function is a function member of a class,
declared using the "virtual" keyword. A pointer to a
derived class object may be assigned to a base class
pointer, and a virtual function called through the pointer.
If the function is virtual and occurs both in the base
class and in derived classes, then the right function will
be picked up based on what the base class pointer "really"
points at.

Is This Answer Correct ?    25 Yes 6 No

what is virtual function?..

Answer / nk

A virtual function is basically a like normal function but
we can override the function in the derived classes.
Now when we want to access like (fn)

Base * bptr = new Derived();
bptr->fn(); then function of the derived class will be
called only if the function is marked as virtual in the
base class.

i.e the virtual keywork tells to use the function of the
class to which it is pointing to and not to the Base class.
This is called runtime polymorphism.

Is This Answer Correct ?    24 Yes 7 No

what is virtual function?..

Answer / laxmikant

A virtual function is a function which is precedded by the
key word derived is declared in the base class.It is
normally used to achieve run time polymerphism.That means
we can override the base class function in the derived
class.We can invoke the virtual function through the base
class pointer depending upon the contents to which the base
class pointer points to.
Generally the implementation of virtual
class was found in inheritance where the base class
function is override in the derived class.

Is This Answer Correct ?    23 Yes 6 No

what is virtual function?..

Answer / shekhar

virtual function is used to prevent from more times
calling.That means if a function is declared as virtual
then its def will be diferent in base class & derived class

Is This Answer Correct ?    11 Yes 0 No

what is virtual function?..

Answer / m.ahmad

Virtual function means the function which is use in base class
and also use in drive class with same name and same arguments
then we use a keyword virtual with base class.

Is This Answer Correct ?    12 Yes 1 No

what is virtual function?..

Answer / gomathisivaram

The virtual function is nothing but the function in the
base class with the virtual keyword, that allows us to
derive only once in the class which is going to accsess it
while it is the child of two different classes which are
the child of the same base class.This is nothing but the
dynamic binding.

Is This Answer Correct ?    18 Yes 10 No

Post New Answer

More OOPS Interview Questions

Please tell me the oops concept with detailed answer

9 Answers   EEE,


How is the using() pattern useful? What is IDisposable? How does it support deterministic finalization?

1 Answers   IntraLogic,


What are the two different types of polymorphism?

0 Answers  


what is difference between objects and function

1 Answers  


What is constructor in oop?

0 Answers  






Write a C++ program to conduct an election of a mayor.Declare a class ELECTION With the following specification: Data member: Name 25 character Age Integer symbol 1 character Member functions: To accept data for 20 contestant To accept symbol as voting from 100 voters. To declare the winner and the loser.

1 Answers   Global Academy, Infotech,


Why do we use oops?

0 Answers  


Why many objects can working together? How objects working togetherM I want to see example code.

2 Answers  


How compiler selects(internally) required overridden function in inheritance?

2 Answers   CSC, Infinite Computer Solutions,


When you define a integer it gets stored in which data structure?(Stack or a heap)

2 Answers   emc2,


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 function of 'this' operator ?

7 Answers   Wipro,


Categories