why return type is not a part of function signature
i.e. I can't make such this code

int x (int y){
return 0;
}
float x(int y){
return 0.0;
}

while i can make such this code:

int x (int y){
return 0;
}
int x(String y){
return 0.0;
}

Recommended Answers

All 3 Replies

There's too much complexity involved in overloading on return type. It's simply not valuable enough to justify the cost of the feature.

because it detect which function should be called from the types of the actual parameters which means a call f(0) and f(0.0) but you dont know f(0) and f(0) if both have different signature (from your point of view that f have an int parameter but different return type) from function call you cant know which one should be called

how mark thread as solved

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.