Take note that virtual functions work on object pointers (and references), but not on regular objects.
When you refer to a derived class object using a pointer or a reference to the base class, you can call a virtual function for that object and execute the derived class’s version of the function.
For non-virtual function, the compiler selects the function that will be invoked at compiled-time (known as static binding).
For virtual functions, the selection is delayed until the runtime. The function selected depends on the actual type that invokes the function (known as dynamic binding or late binding).