Virtual Keyword
Title
Question
What is the meaning of the keyword Virtual that is used with operation function?
Advanced-Cpp Function-Overloading-And-Overriding 03-04 min 20-30 sec
Answers:
Dear Mann_19,
nags
The keyword virtual in C++ tells the compiler to support runtime polymorphism.
When used with a function (like virtual void operation()), it means that the function can be overridden in derived classes, and the correct version will be called based on the actual object type at runtime — even if accessed through a base class pointer or reference.
Login to add comment