overloading methods

Jan 29, 2009 at 12:48pm
HI,
why the compiler consdier the arguments of method while calling overloaded function and not function return type.

thanks in advance............
Jan 29, 2009 at 1:11pm
Overloaded functions are recognized by the different arguments they have
eg:
Right Overload:
1
2
int f( int );
int f( double );

Wrong Overload:
1
2
int f( int );
double f( int );//same arguments, the compiler wouldn't know which to call 

http://www.cplusplus.com/doc/tutorial/functions2.html#function_overload
Jan 29, 2009 at 2:14pm
He's asking why that is the case, not for the fact that it is.

I think it is just that determining which to call is a good bit more difficult if the return type were considered than just the argument lists.

Hope this helps.
Topic archived. No new replies allowed.