如果:
int var = 0;
&var; //--> returns the address of "var"
和
int *p = &var;
*p; //--> returns the value pointed to by "p", the value stored in "var"
然后不应该(但多余):
*&var; //--> returns the value stored in "var"
*var; //--> throw an error (or return the value stored in "var")?
我现在无法编译C ++代码,但我想弄清楚这些运算符。
答案 0 :(得分:4)
*&var; //--> returns the value stored in "var"
是的,&var
是一个指向var
的指针,然后*&var
与var
相同。
*var; //--> throw an error (or return the value stored in "var")?
这不会编译,因为您不能尊重int
。