Is it safe to #define NULL nullptr?

前端 未结 6 849
囚心锁ツ
囚心锁ツ 2021-02-02 06:38

I have seen below macro in many topmost header files:

#define NULL 0  // C++03

In all over the code, NULL and 0 are u

6条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-02 07:11

    While it might break backwards-compatibility with older stuff that was badly written (either that, or overly clever...), for your newer code, this is a non-issue. You should use nullptr, and not NULL, where you mean nullptr. Also, you should use 0 where you mean zero.

提交回复
热议问题