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
What are the benefits of polymorphism?
What is encapsulation and abstraction? How are they implemented in C++?
What does and I oop mean in text?
c++ program to swap the objects of two different classes
What is destructor in oop?
What is destructor example?
can inline function declare in private part of class?
What is the real time example of inheritance?
Write a c++ program to display pass and fail for three student using static member function
What is the benefit of oop?
What is constructor in oop?
What is a superclass in oop?
How do you achieve runtime polymorphism?
What is static in oop?
How can you overcome the diamond problem in inheritance?