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
What is protected in oop?
What is abstraction and encapsulation?
What is difference between inheritance and polymorphism?
What is encapsulation with example?
Why multiple inheritance is not possible?
How do you answer polymorphism?
State what is encapsulation and friend function?
Why is polymorphism used?
How to use CMutex, CSemaphore in VC++ MFC
How oops is better than procedural?
What is the benefit of oop?
Why is oop better than procedural?
any one please tell me the purpose of operator overloading
What are two types of polymorphism?
Why do pointers exist?