Cpp_Primer_Practice
Cpp_Primer_Practice copied to clipboard
【报错】练习2.32
合法。指针可以初始化为 0 表示为空指针。
int null=0, *p=null 无法通过编译,报错
error: cannot initialize a variable of type 'int *' with an lvalue of type 'int' int *p = null; ^ ~~~~
但是int null=0, *p=0 可以通过编译
《c++ primer 中文版 5th》p49 把int变量直接赋给指针是错误的操作,即使int变量的值恰好等于0也不行。
是不合法的, 答案给错了. 看这个问题 https://www.zhihu.com/question/264940525?sort=created