cmath vs math.h (And similar c-prefixed vs .h extension headers)

前端 未结 4 666
一整个雨季
一整个雨季 2020-12-08 00:04

I\'ve seen some information about differences between things like iostream vs iostream.h. From what I gathered from those the difference between th

4条回答
  •  有刺的猬
    2020-12-08 00:54

    and any header are standard C++, meaning you have strong guarantees of what is supported in those headers and how the functions in them work, as outlined in the C++ Standard. They define a series of functions in the std namespace, and that's it.

    and any headers are not standard C++, despite being supported on every major implementation. However, since they are deprecated, there is no guarantee of what is inside those headers when you include them on your implementation. In fact, it has been observed on certain implementations that they provide functions that behave differently to the versions.

    Therefore, you should always use when writing C++, and qualify the names of the functions with std::, for example std::malloc.

提交回复
热议问题