【发布时间】:2011-05-17 12:33:15
【问题描述】:
为什么下面代码中的 if 条件为真?
struct A
{
int firstMember;
} a1;
if (&a1 == static_cast<void*>(&a1.firstMember)) std::cout << "equal";
在阅读空类的Stroustrup's FAQ 时,我有点困惑,特别是下面的语句:
if (p1 == p2) cout << "nice: good optimizer";
【问题讨论】:
标签: c++ pointers object member object-layout