|
|
|
|
|
by bff
5796 days ago
|
|
Return types can't always be deduced since they can be ambiguous - imagine an if statement where one branch returns a float and the other returns a double. The desired return type could really be any numeric value since the types can be converted so the return type does need to be specified. Since C++ has overloaded functions the compiler can't just look at the function that the result is being passed into to determine the type either. |
|
The compiler already deals with this issue with the ?: operator. It's a readability and maintenance problem there, too. It'd be easy to do; the language designers chose not to.