polymorphism means one message peforms different operations on the object which it receives.
then " what is the benefit of polymorphism in c++?"?why polymorphism?
suppose you consider function overloading.
what is the benefit of using same function for different purposes?
can you explain clearly?
polymorphism occurs at run time while function overloading occurs at compile time,. That said, they are both advantages in that they reduce writing different functions for related objects. say for example you have a bird class..where there are different kind of birds, the ostrich, the kiwi, the sparrows and so on..it would be against OOP principle to start writing different function to identify each individual bird type. you could just write a single function that shows the relationship between these different birds. Code-reuse is part of OOP and that is where polymorphism(having different operation) and function overloading come in. I hope this clarifies your question?