I know how Polymorphism works, but I am trying to understand in what cases is Polymorphism useful.
Now All the examples that I have found about Polymorphism are one of the following (the below code is in C++):
Either we have an array of type
Base*that holds pointers to objects derived from the
Baseclass, and then we loop through the array and call something like
Or we have a function that have a
Base*parameter, and then we call this function and pass it a pointer to any of the objects derived from the
Are these the only cases where Polymorphism is useful?