'sqrt' is not a member of 'std'

Yakov picture Yakov · May 13, 2013 · Viewed 36.9k times · Source

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

std::sqrt((double)num);

On windows it is ok,but on linux I get 'sqrt' is not a member of 'std' I have an include for math.h

what is a problem with it?

Answer

jrok picture jrok · May 13, 2013

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.