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?

Recommended Answers

All 2 Replies

Read this link and you will see that none of the overloaded functions take two integers.

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.

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.