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?
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?
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.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.