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

Finding of the 4 larger (bigger) numbers from the list like{1245,4587,2145,1163,29987,65783.....}

1 Answers   Wipro,


What are oops functions?

0 Answers  


what is the difference between class and structure in C++?

9 Answers   Aspire, IBS, TCS,


What is an advantage of polymorphism?

0 Answers  


Have you ever used threads?

3 Answers   Adobe, IBM,






Prepare me a program for the animation of train

0 Answers  


Write an operator overloading program to Overload ‘>’ operator so as to find greater among two instances of the class.

1 Answers  


What is difference between #define and const?

3 Answers   emc2,


What is data binding in oops?

0 Answers  


What is encapsulation with example?

0 Answers  


what is multithreading in c++ , what is difference between multithreading and singlethreading.

4 Answers  


write a code for this:trailer recordId contains a value other than 99, then the file must error with the reason ‘Invalid RECORD_ID’(User Defined Exception).

0 Answers  


Categories