error!



hi,

how to solve these errors ?

error C2668: 'exp' : ambiguous call to overloaded function
error C2668: 'pow' : ambiguous call to overloaded function
error C2668: 'sqrt' : ambiguous call to overloaded function
closed account (zb0S216C)
You need to post the code where the error's are occurring in order for us to help you.

n2 = exp(-n)*pow(n,n)*sqrt((157/25)*n);

btw n2 is double
closed account (zb0S216C)
Of what type is n?
In my opinion, your code is a mess. Try splitting each method call, like this:

1
2
3
4
5
6
7
8
9
int main( )
{
    double n( 0.0 );   
    double Exp( exp( n ) );
    double Pow( pow( n, n ) );
    double Sqrt( sqrt( ( 157 / 25 ) * n ) );

    double n2( Exp * Pow * Sqrt );
}


exp(-n)

Did you mean: exp( n ) ? or exp( --n )?
The problem is that n is probably an int, and those functions are overloaded to take either doubles or floats, so the compiler can't tell which version it should use (since an int can be converted to both types). And I don't think it's messy at all, though it could use some whitespace around operators.
Yep, Frame yours actually looks more messy lol.
closed account (zb0S216C)
Yep, Frame yours actually looks more messy lol

Lol. Maybe so :)P but n2 = exp(-n)*pow(n,n)*sqrt((157/25)*n); hurts my eyes because it's squashed together. Truthfully, I can't stand code written like that :)


my n is int , and n2 is double ==> here is the problem

then, I have to put double before each n .

.....

Thanks for helping :>

my n is int , and n2 is double ==> here is the problem

No, it has nothing to do with n2. Read my previous post.

Yes you are right , I didn't change the type of n2

I've only added double before n ,
or I could change the type of n from int to double it works as well .
......

Thanks filipe your comments helped me. :>
Topic archived. No new replies allowed.