In the aforementioned program bp is a pointer of type Base. A call to bp->show() calls show() function of the Derived class. This is because bp points to an object of the Derived class.
Things essential to writing a virtual function in C++ are:
1. A base class
2. A derived class
3. A function with the same name in both the classes i.e. the base class and the 4. derived class
5. A pointer or reference of base class type that points or refers, respectively to an object of the derived class
Now i have clear about virtual functions in C++, thanks to this
post. It's very useful and helpful.