【发布时间】:2014-02-28 21:07:28
【问题描述】:
这不是逻辑:
int *ptr = &otherInt;
当我们这样做时,ptr 给出 otherInt 的地址,*ptr 给出 otherInt。
但我们明确写出 (*ptr) 等于地址 *ptr = &otherInt !
从逻辑上讲,*ptr 应该给出地址,ptr 应该给出 otherInt。
你不觉得吗?
【问题讨论】:
这不是逻辑:
int *ptr = &otherInt;
当我们这样做时,ptr 给出 otherInt 的地址,*ptr 给出 otherInt。
但我们明确写出 (*ptr) 等于地址 *ptr = &otherInt !
从逻辑上讲,*ptr 应该给出地址,ptr 应该给出 otherInt。
你不觉得吗?
【问题讨论】:
我认为你完全错了。考虑一下:
int *ptr;
int otherInt = 10;
ptr = &otherInt; // Notice this line.
星号是声明的一部分,而不是赋值。
【讨论】:
int* ptr;