Polymorphism is needed so that a program can decide which function to run based on the actual object type at runtime. In C++, this is done using virtual functions. A base class pointer can point to different derived class objects. When calling a virtual function through this pointer, the program runs the derived class's version, not the base class's. This behavior allows writing flexible code that works correctly with many types. If the function is not virtual, the base class version always runs, which is usually not what we want. The example shows an Animal pointer pointing to a Dog object. Calling sound() runs Dog's sound(), printing 'Bark'. This is polymorphism in action.