Assign integer literal to pointer?

后端 未结 5 1898
说谎
说谎 2021-01-15 14:20

This question might be too bad but I can take risk to post this question here to address my confusion.

Actually my question is that we can only assign address to poi

5条回答
  •  醉梦人生
    2021-01-15 15:05

    No it does not break the rule. The integer constant 0 (and generally any constant expression evaluating to 0) is treated specially and it is allowed to assign such value to a pointer. It does not mean that you can assign any integer - just zero.

    The current version of C++ introduces the new nullptr keyword which should be used instead.

提交回复
热议问题