what if bill is inherited in a derived class discountsale with a different bill() version than just return original price from class Sale.
a) bill() is virtual function
b) bill() is non-virtual
The difference is evident in objects allocated in stack (with new). To be more specific let's say we have 2 objects:
one from the base class B with a virtual function vfunc() and
one from the derived class D with a different virtual function [code]vfunc().
The compiler recognized the real type of each object and calls the correct function.
If the functions weren't virtual then only the static type of each object would be used:
If a base* B is used then ALWAYS the function of the base class will be called regardless of the dynamic type of B (B could point to a base object or a derived object)