c++mathstdsqrt

'sqrt' is not a member of 'std'


I compile my program in Linux - it has the following line:

std::sqrt((double)num);

On Windows, it is ok. However, on Linux, I get an error:

sqrt is not a member of std

I have already included math.h.

What is the problem with that?


Solution

  • Change the directive to #include <cmath>. C++ headers of the form <cxxxxxxx> are guaranteed to have the standard names in std namespace (and may optionaly provide them in global namespace). <xxxxxx.h> are not.