Function overloading question

Random snip-it from http://www.tutorialspoint.com/cplusplus/cpp_overloading.htm:

"You can have multiple definitions for the same function name in the same scope. The definition of the function must differ from each other by the types and/or the number of arguments in the argument list. You can not overload function declarations that differ only by return type."

"Must differ from each other by the type [..] You can not overload function declarations that differ only by return type."

What? So to overload you only have to change the function type.. but you can't overload by return type? isn't the function type the return type?

Last edited on
"Must differ from each other by the type [..]

Where on that page is such exact sentence?
Overloaded functions must have different types and/or numbers of parameters. They cannot differ by return type only. For example:

1
2
3
4
5
void f(int);
void f(int, int);  // okay: different number of arguments
void f(std::string &);  // okay, different parameter type

int f(int);  // illegal. Same parameter list as void f(int) 
Topic archived. No new replies allowed.