what is virtual function?
Answer Posted / 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 |
Post New Answer View All Answers
when to use 'mutable' keyword and when to use 'const cast' in c++
Which method cannot be overridden?
What is abstract class in oop?
What are oops methods?
What is encapsulation c#?
What are the 3 pillars of oop?
What is overloading in oop?
What is polymorphism give a real life example?
What is oops with example?
What is the main feature of oop?
How can you overcome the diamond problem in inheritance?
What is the significance of classes in oop?
What is a class in oop?
What are the 5 oop principles?
What is the diamond problem in inheritance?