C++ standard library includes most of the C library (there are some hazy details around optional parts of the C library).
Since C has no concept of namespacing, everything included from the C library will be in the global namespace. Since <math.h>
is a C header, its functions are put into global namespace.
Everything included from the C++ standard library will be in the std::
namespace, like std::ifstream
when you included <fstream>
header.
Where it gets fun, are aliases. As an example, <math.h>
can also be included as <cmath>
. The idea behind this was that you select whether you want the C symbols in global namespace (including <math.h>
) or in the std::
namespace (including <cmath>
), but this didn't work out and generally if you include the C++ version of the header (ie <cmath>
), you will get both.
Generally, if a header can either be included via <foo.h>
or via <cfoo>
, its a C header. C++ standard library headers do not have these aliases (except when you have to deal with non-standard things like iostream.h
that apparently still exist on some platforms).