Re: Inheritance and offsetof
On Sep 24, 11:56 am, "Francesco S. Carta" <entul...@gmail.com> wrote:
On 24 Set, 09:40, James Kanze <james.ka...@gmail.com> wrote:
[...]
So, if I finally got it (and your explanations) straight, PODs
_have_ well defined, mandated layouts, while all other
user-defined classes/ structs have no mandated layout at all.
POD's don't have a defined layout either. All you're guaranteed
is that if there is no change of access between two *members*
(no guarantee what so ever for base classes) of a class, then
they will be layed out in the order they are declared. With
more or less padding between them.
In practice, of course, most systems define the layout of a C
struct as part of their system ABI, and any C++ implementation
will conform to this for POD's, and probably for all layout not
involving inheritance. Under Windows on a PC, or under Solaris
on a Sparc, for example, you know the layout of a POD. Not from
the C++ standard, of course, but from the system ABI
specification.
--
James Kanze