this is simply because <math.h> does not declare functions in namespace std . It was included in the C ++ standard only for compatibility reasons. The correct C ++ include will be <cmath> .
ยงD.5,2
Each C title, each of which has a name of the form name.h , behaves as if each name placed in the standard library namespace with the corresponding cname header is placed in the global namespace area. It is not known whether these names will be first declared or defined in the std namespace scope and then entered into the global namespace scope using explicit use-declarations.
For your code to work under windows, it was pure luck - if you want to call it that. The last sentence gives a hint what can happen under windows, but not under Linux: under windows, obviously, the names are valid both in the global namespace and in the std .
Arne mertz
source share