michael
2011-06-29 05:43:13 UTC
i'm trying to declare a variable with the square root function found in cmath. Code below.
double sqt_of_n = sqrt(n);
where n is of type int;
My IDE is Microsoft visual C++ and when trying to compile it, it is throwing up errors with this piece of code. Error below:
1>chapter4.cpp(98): error C2668: 'sqrt' : ambiguous call to overloaded function
1> C:\Program Files\Microsoft Visual Studio 10.0\VC\include\math.h(589): could be 'long double sqrt(long double)'
1> C:\Program Files\Microsoft Visual Studio 10.0\VC\include\math.h(541): or 'float sqrt(float)'
1> C:\Program Files\Microsoft Visual Studio 10.0\VC\include\math.h(127): or 'double sqrt(double)'
If i convert the int to double before using it works fine, I dont understand why i cant convert to double and square root at the same time. Is this just my IDE?
Many thanks