Virtual functions allow functions in derived classes to override functions in base classes. When a base class pointer points to a derived class object, calling a virtual function through the pointer will call the derived class's version. This allows the same interface to behave differently based on the actual object. Virtual functions are useful for mathematical operations, where a base class defines an interface and derived classes perform specific calculations like addition, subtraction etc. depending on the object type pointed to by the base class pointer.