void f(void) { // ... } void f(int i) { // ... } void f(MyClass x) { // ... }
Overloading is possible because a C++ compiler can differentiate which function to use by context. In other words, a C++ compiler knows which actual subroutine to use in the following code:
{ MyClass mine; f(mine); }
Overloading comes in handy because we don't need to invent new names for the same abstract operation on different types. However, this convenience is not important compared to the possibility of using template functions and template classes.