what is virtual function?
Answers were Sorted based on User's Feedback
Answer / purba phalguni mishra, gandhi
The objects of the polymorphic class, addressed by
pointers, change at runtime and respond differently for the
same message.Such mechanism requres postponment of binding
of a function call to the member function [ VIRTUAL] untill
runtime.
| Is This Answer Correct ? | 15 Yes | 9 No |
Answer / varun sir
a virtual function is used to avoid duplicacy in derived
classes. suppose that there is a base class which has two
properties a and b. now suppose that two derived classes
named 'der1' and 'der2' are deriving from that base class,
then both properties a and b of base class will be
inherited to both of the derived classes. now if a new
class is derived from 'der1' and 'der2' then both of the
properties a and b of 'der1' and 'der2' will also be
inherited into newly derived class. this will cause
duplicacy in newly obtained derived class. so in order to
avoid this duplicacy , we use virtual functions.
| Is This Answer Correct ? | 8 Yes | 6 No |
Answer / pooja pimplapure
Virtual, as the name implies, is something that exists in
effect but not in reality. The concept of virtual function
is the same as a function, but it does not really exist
although it appears in needed places in a program. The
object-oriented programming language C++ implements the
concept of virtual function as a simple member function,
like all member functions of the class.
The functionality of virtual functions can be over-ridden
in its derived classes. The programmer must pay attention
not to confuse this concept with function overloading.
Function overloading is a different concept and will be
explained in later sections of this tutorial. Virtual
function is a mechanism to implement the concept of
polymorphism (the ability to give different meanings to one
function).
| Is This Answer Correct ? | 4 Yes | 2 No |
Answer / b.mamatha
A virtual function or virtual method is a function or method
whose behaviour can be overridden within an inheriting class
by a function with the same signature. This concept is a
very important part of the polymorphism portion of
object-oriented programming (OOP).
| Is This Answer Correct ? | 2 Yes | 0 No |
Answer / diwakar saraswat
virtual function is a member function of the class.
virtual function declare with virtual keyword.
once virtual function declare in base class, we can define
this function in drive class.
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / bhupendra more
A function qualified by the virtual keyword. When a virtual
is called via a pointer,the class of the object pointed to
determine which function definition will be used. Virtual
function implement polymorphism. whereby objects belonging
to different classes can respond to the same massage in
different way.
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / vindhyachal kumar gupta
C++ virtual function is a member function of a class, whose
functionality can be over-ridden in its derived classes. The
whole function body can be replaced with a new set of
implementation in the derived class. The concept of c++
virtual functions is different from C++ Function overloading.
C++ Virtual Function - Properties:
C++ virtual function is,
* A member function of a class
* Declared with virtual keyword
* Usually has a different functionality in the derived class
* A function call is resolved at run-time
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / ann
A virtual function is a function which is preceded by the
keyword 'virtual' followed by its normal declaration.When we
use the same function name in both the base and derived
classes,the function in base class is declared as virtual.
This concept is a very important part of the
polymorphism portion of object-oriented programming
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / chandan jena
To make a class polymorphic we use virtual function.It
provides runtime polymorphism.
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / dev malhotra
virtual function is defined as virtual is a keyword which is used when one function or method is used in both base class and drived class at a time then, during compile time compiler cannot distinguish that which one compile or run first.
then to distinguish that problem the programmer use special keyword in base class or in derived class that is known as "VIRTUAL" keyword.
Due to this keyword the compiler always compiles the assigned virtual keyword method or function and this is called as virtual function.
| Is This Answer Correct ? | 0 Yes | 0 No |
what is inline function?
What is function overloading?,describe it with the example.
Can enum be null?
c++ program to swap the objects of two different classes
string is a class or data type in java?
What is encapsulation in ict?
What is abstraction example?
What are main features of oop?
What is encapsulation c#?
What is object and example?
Child cObj = new Parent() Wahts the output ?
how to find the largest of given numbers in an array