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

what about you? wahat is your object? introduce your self?

1 Answers   Ajmal Perfumes, TCS,


What is multiple inheritance?

9 Answers   TCS,


What are classes oop?

0 Answers  


What do we mean by a hidden argument in a function?

1 Answers   TCL,


what are abstract classes and how they impliment , with example

2 Answers  






what is diff between .net 1.1 and .net 2.0

4 Answers  


What is the advantage of oop over procedural language?

0 Answers  


What is this pointer in oop?

0 Answers  


What do you mean by variable?

0 Answers  


what is function over loading?

5 Answers  


What is polymorphism and why is it important?

0 Answers  


Why is abstraction used?

0 Answers  


Categories