About this document
Understanding C++ Virtual Functions by Raghavendra Rajendra Basvan is a document available to read on EtoBox.
A virtual function is a member function declared in a base class that is overridden by derived classes. When a virtual function is called through a base class pointer, the version of the function in the most derived class is executed. This allows for runtime polymorphism. In the example code, class B derives from class A and overrides the virtual show() function. When show() is called using a base class pointer pointing to a B object, the version in B is executed and prints the value of b.
- Author
- Raghavendra Rajendra Basvan
- Language
- EN