Topic: Memory layout of an object


Author: Michiel.Salters@cmg.nl (Michiel Salters)
Date: Tue, 15 Jan 2002 15:11:16 GMT
Raw View
"jum" <juergen_3333@gmx.de> wrote in message news:<a1sche$cdo$07$1@news.t-online.com>...
> Hi,
> is the memory layout (data, function pointers) of an object of a class ISO
> specified?
> Best Regards
> Juergen

Mostly not.
There are some things you can depend on: The order of members in the
layout is the same as the order of declaration, if they are in the
public/protected/private section. For POD classes, you can use the
offsetof macro and get integral offsets; for other classes you can
use pointers to members which encapsulate the offsets.

Regards,

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]





Author: "jum" <juergen_3333@gmx.de>
Date: Mon, 14 Jan 2002 15:36:38 GMT
Raw View
Hi,
is the memory layout (data, function pointers) of an object of a class ISO
specified?
Best Regards
Juergen

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]





Author: "Scott Robert Ladd" <scott@coyotegulch.com>
Date: Mon, 14 Jan 2002 16:28:34 GMT
Raw View
> is the memory layout (data, function pointers) of an object of a class ISO
> specified?

No.

This is probably due to the platform-independence of POD representations and
function semantics; i.e., the ISO standard can't say that an "int" looks a
certain way in memory because an "int" may vary in definition between
platforms.

--
Scott Robert Ladd
Master of Complexity, Destroyer of Order and Chaos
  Visit CoyoteGulch at http://www.coyotegulch.com
    No ads -- just info, algorithms, and very free code.


---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]