Question:
help with this c++ error?
2007-12-14 12:52:49 UTC
When I run my program, I get these errors, even though I have I have added "#include "!
Will anyone help me how to fix them, please!

thank you!

/usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/cmath:361: no te: long double std::pow(long double, int)
/usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/cmath:357: no te: float std::pow(float, int)
/usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/cmath:353: no te: double std::pow(double, int)
Three answers:
2007-12-14 14:07:25 UTC
The signature for pow() is:



double pow(double x, double y);



Change your second parameter from int to double. Changing your return variable to a double is also advisable.

.
2007-12-14 12:59:29 UTC
Converting from float, double or long double to int sometimes causes problems. First I would suggest running the compiled program and see if it runs properly (in my experience, often the program will run just fine despite the compiler giving you a warning). If you're sure the program's behavior is actually bugged, then you'll have to find some way to convert between different variable types. Unfortunately I don't know exactly how this is done, I'm still a noob at C++.
PinkeiKong
2007-12-15 23:42:53 UTC
#include



//your function should be



{

double pow (double variable1, double variable2);

}



from

keng ping kong from www.iwohoo.com and www.pinkeikong.com


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...