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 is data binding in oops?
What is property in oops?
What is polymorphism what are the different types of polymorphism?
How Do you Code Composition and Aggregation in C++ ?
What is the use of oops?
Question: Implement a base class Appointment and derived classes Onetime, Daily, Weekly, and Monthly. An appointment has a description (for example, “see the dentist”) and a date and time. Write a virtual function occurs_on(int year, int month, int day) that checks whether the appointment occurs on that date. For example, for a monthly appointment, you must check whether the day of the month matches. Then fill a vector of Appointment* with a mixture of appointments. Have the user enter a date and print out all appointments that happen on that date.
Which language is pure oop?
write knight tour problem which is present in datastructure
How to improve object oriented design skills?
What is static modifier?
What is a class in oop?
Will I be able to get a picture in D drive to the c++ program? If so, help me out?
What is abstraction and encapsulation?
#include
What is multilevel inheritance explain with example?