what is virtual function?
Answer Posted / 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 |
Post New Answer View All Answers
Why do we use inheritance?
What is new keyword in oops?
What causes polymorphism?
How can you overcome the diamond problem in inheritance?
#include
What is constructor in oop?
Will I be able to get a picture in D drive to the c++ program? If so, help me out?
What is stream in oop?
What is the point of polymorphism?
What is the difference between inheritance and polymorphism?
What is oops in simple words?
what is difference between class template and template class?
What is pure oop?
What polymorphism means?
What is abstraction with example?