文章目录
Chapter 3. The Semantics of Data
class X {
};
class Y : public virtual X {
};
class Z : public virtual X {
};
class A : public Y, public Z {
};
sizeof X yielded 1
sizeof Y yielded 8
sizeof Z yielded 8
sizeof A yielded 12
3.1 The Binding of a Data Member
3.2 Data Member Layout
The static data members are stored in the program’s data segment independent of individual class objects.
The Standard allows the compiler the freedom to order the data members within multiple access sections within a class in whatever order it sees fit
template< class class_type,
class data_type1,
class data_type2 >
char*
access_order(
data_type1 class_type::*mem1,
data_type2 class_type::*mem2 )
{
assert ( mem1 != mem2 );
return