According to the definition for virtual function is "Virtual functions are member functions whose behavior can be overridden in derived classes. ".What is the meaning of this? Also, why virtual function uses pointers?
A virtual function is a member function that you expect to be redefined in derived classes. 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. Virtual functions ensure that the correct function is called for an object, regardless of the expression used to make the function call. Suppose a base class contains a function declared as virtual and a derived class defines the same function. The function from the derived class is invoked for objects of the derived class, even if it is called using a pointer or reference to the base class. Virtual functions are called only for objects of class types, you cannot declare global or static functions as virtual.