An overloaded function can be differentiated using:
- Number of parameters
- Types of parameters (includes ellipses parameters)
Please note that type aliases are not distinct and so can’t be used for differentiation.
Also, return type can’t be used for differentiation and this makes sense how can a compiler know which function to invoke on return type. For example,
int callme()
{
return 1;
}
double callme()
{
return 1.0;
}
callme();Compiler would not know which one to call. For this, compiler has to be smarter which can determine the type where the call has been made etc.