The standard requires within an access section only that the members be set down such that "later members have higher addresses within a class object". That is, the members are not required to be set down contiguously. What might intervene between the declared members? Alignment constraints on the type of a succeeding member may require padding.
The compiler may synthesize one or more additional internal data members in support of the Object Model. The standard, by phrasing the layout requirement as it does, allows the compiler the freedom to insert theres internally generated members anywhere. Where should the vptr be placed within the class object? More recently, it has been placed at the beginning of the class object. Also in practice, multiple access sections are concatenated together into one contiguous block in the order of declaration. No overhead is incurred by the access section specifier or the number of access levels.
No comments:
Post a Comment