Object layout in C++ and access control

时间:2023-03-09 05:41:38
Object layout in C++ and access control

The variables are guaranteed to be laid out contiguously, as in C. However, the access blocks may not appear in the object in the order that you declare them.

Access specifier are part of the structure and donot affect the objects created from the structure. All of the access specification information disappears before the program is run; generally this happens during compilation. In a running program, objects become "regions of storage" and nothing more.    (Page 270)

In fact, the compiler is the only thing that kowns about the protection level of class members. There is no access control information mangled into the member name that carries through to the linker. All the protection checking is done by the compiler; it has vanished by runtime.    (Page 275)