If I define
thenCode:struct A { float x,y,z; A(xx,yy,zz) { x=xx;y=yy;z=zz;}; virtual ~A(void) {}; }
Can I be certain that the member variables of A will appear in memory in the right order like an array, in spite of the fact that A has a virtual function table? Is this part of the C++ spec? Is it true of all platforms and implementations?Code:A a(0.0,1.0,2.0); float* p2; p2 = reinterpret_cast<float*>(&a); float f; f = p2 [2]; assert(f==a.z);




Reply With Quote