<分区>
以下代码可以在 C 中编译,但不能在 C++ 中编译:
int *ptr = 25; //why not in C++?
错误
prog.cpp: In function ‘int main()’:
prog.cpp:6:11: error: invalid conversion from ‘int’ to ‘int*’ [-fpermissive]
int *ptr = 25;
但这在 C 和 C++ 中编译:
int *ptr = 0; //compiles in both
为什么分配 0 可以正常工作而其他数字不起作用?