Reputation: 21025
I am writing a C++ program using Xcode, and I need to find the max and min of two numbers. I decided to use the built-in max
and min
functions of C++.
When I do :
float result = min(x1,x2); // x1, x2 are floats
Xcode recognises min
just fine.
But when I do:
float result = max(x1,x2); // x1, x2 are floats
Xcode complains with the error:
No matching function for call to 'max'
If I COMMAND + Click on either max
or min
, the Xcode quickly takes me to the function definitions, so clearly Xcode knows they are both there.
How do I get max
to work ?
EDIT: I have tried calling std::max, but I get the same error.
Upvotes: 0
Views: 912
Reputation: 142
This type of error occur generally when your parameters that you are passing to min or max function is not of same type.
Make sure to check the parameter type of both parameters.
Upvotes: 1