difference between polymorphism and overloading

user3500089 picture user3500089 · Apr 5, 2014 · Viewed 19.2k times · Source

I found there has many definition about polymorphism and overloading. Some people said that overloading is one type of polymorphism. While some people said they are not the same. Because only one function will be allocate in overloading. While the polymorphism need allocate the memory for each redefined member function. I really feel confusion about this, any one could explain this for me? Further, whether overloading happens at compile time while the polymorphism happens at running time?

Answer

deb_rider picture deb_rider · Apr 5, 2014

Polymorphism is the process to define more than one body for functions/methods with same name.

Overloading IS a type of polymorphism, where the signature part must be different. Overriding is another, that is used in case of inheritance where signature part is also same.

No, it's not true that polymorphism happens in runtime. What happens in runtime is called runtime polymorphism. That is implemented using virtual keyword in C++.

Hope it helped..