【发布时间】:2015-06-11 02:56:29
【问题描述】:
我正在查看 Dev-Cpp 的包含文件中的 stdlib.h,我发现了某行:
#define _PTR_LD(x) ((unsigned char *)(&(x)->ld))
然后我尝试在程序中使用 _PTR_LD,如下所示:
class Thing {
public:
Thing();
int ld;
};
int main() {
Thing x;
x.ld = 8;
cout << _PTR_LD(x) << endl;
system("pause");
return 0;
}
我以为它会返回 x 中属性 ld 的值,但我收到以下错误消息:
15 10 C:\Users\John\Desktop\Untitled1.cpp [错误] '->' 的基本操作数具有非指针类型'Thing'
我试图搜索 _PTR_LD() 但我一无所获。有人知道 _PTR_LD() 吗?
【问题讨论】:
-
需要传递一个指针,操作顺序为
&(x->ld)。它还评估为unsigned char *,所以我将0x38分配给x.ld。
标签: c++