A virtual function is a base class member function that we expect to redefine in derived classes.
In the base class, a virtual function is used to ensure that the function is overridden. 
This is especially true when a pointer from a base class points to an object from a derived class.
For example, consider the code below:
class Base {
   public:
    void print() {
        // code
    }
};
class Derived : public Base {
   public:
    void print() {
        // code
    }
};