when i try to use pow with cmath header i get error message pow(int,int)is ambiguous
it also gives other possible options i.e pow(double,int)

why is int^int ambiguous? how could it be less ambiguous?

8 Years
Discussion Span
Last Post by Fbody

C++ automatically "promotes" values to the appropriate data types for certain operations. An int can be promoted to any of float, double, or long double. As a result, any of those versions of the function is an appropriate function call.

To get around it, simply cast the first argument to one of those 3 types. The cast will eliminate the need to "promote" the argument because you have explicitly stated which version of the function you would like.

Edited by Fbody: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.