cmath header confusion

前端 未结 4 1823
深忆病人
深忆病人 2020-12-11 21:00

What is the namespace for math functions? Global or std?

Consider cos function. It has 3 overloads. But there is also legacy cos from math.

4条回答
  •  甜味超标
    2020-12-11 21:37

    You get the same functions by including and in C++, the only differences is the namespace. I.E. including also gives you the overload.

    In theory, in C++03, using gives you the symbols defined in the global namespace and also in the std namespace while using gives you the symbols defined in the std namespace and not in the global namespace.

    The practice is different and C++ 0X aligned the theory with the practice. gives you the symbols defined in the global namespace and perhaps also in the std namespace while using gives you the symbols defined in the std namespace and perhaps also in the global namespace.

提交回复
热议问题