Код: Выделить всё
struct Vec2 {
float x,y;
Vec2():x(0),y(0) {
printf( "Construct Vec2 %f %f\n",x,y );
}
};
struct Rectangle {
union {
struct { float x,y; };
Vec2 pos;
};
union {
struct { float w,h; };
Vec2 size;
};
Rectangle(){
printf( "construct Rectangle %f %f %f %f\n", x,y,w,h );
}
}
int main() {
Rectangle r;
}
Меня очень удивил вопрос, почему это так?
Подробнее здесь: https://stackoverflow.com/questions/785 ... nstructors