# C++: Overloading on return values is NOT allowed (neither in java)

Yao Yao on March 24, 2015
• Published in category
• C++

void f();
// int f(); // ERROR


If overloading on return values was permitted, how can the compiler distinguish which call is meant in int x = f( );? Possibly worse is the difficulty the reader has in knowing which function call is meant. Overloading solely on return value is a bit too subtle, and thus isn’t allowed in C++.