我是一个C++菜鸟,我很确定这是一个愚蠢的问题,但我不太明白为什么从以下代码出现错误(不会出现):
#include <iostream>
using namespace std;
int main()
{
int a,*test;
*test = &a; // this error is clear to me, since an address cannot be
// asigned to an integer
*(test = &a); // this works, which is also clear
return 0;
}
Run Code Online (Sandbox Code Playgroud)
但为什么这也有效呢?
#include <iostream>
using namespace std;
int main()
{
int a, *test= &a; // Why no error here?, is this to be read as:
// *(test=&a),too? If this is the case, why is the
// priority …Run Code Online (Sandbox Code Playgroud)