12/06/13 01:46:00.21
>>728
>>732と同じ方向性だが最初からC++っぽい設計にしとけば悩むほうが難しいくらいだったろうに
union foo { int f; };
struct bar {
foo a;
struct { int b; };
int get_f() { return a.f; }
int get_b() { return b; }
};
int main()
{
bar zot;
zot.b = 123;
zot.a.f = 456;
int (bar::*p)() = &bar::get_b;
int x = (zot.*p)(); // is zot.b
int (bar::*q)() = &bar::get_f;
int y = (zot.*q)(); // is zot.a.f
std::cout << x << std::endl;
std::cout << y << std::endl;
return 0;
}