Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Memory layout of an object with multiple inheritance

Reply
Thread Tools

Memory layout of an object with multiple inheritance

 
 
stasgrom@gmail.com
Guest
Posts: n/a
 
      10-08-2006
Guys, I have this situation: the class C is defined as follow:

class C: public A, public B {...};

Now when I create an object of class C, I can see that the compiler (VS
8.0) decides to layout the memory of this object so that the fields of
class B come before the fields of class A. I always thought the layout
is defined by the order of inheritance. Was I wrong?

Thanks.

 
Reply With Quote
 
 
 
 
Thomas Tutone
Guest
Posts: n/a
 
      10-08-2006
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:

> Guys, I have this situation: the class C is defined as follow:
>
> class C: public A, public B {...};
>
> Now when I create an object of class C, I can see that the compiler (VS
> 8.0) decides to layout the memory of this object so that the fields of
> class B come before the fields of class A. I always thought the layout
> is defined by the order of inheritance. Was I wrong?


Yes, you were wrong. It's implementation defined.

Best regards,

Tom

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
inheritance, multiple inheritance and the weaklist and instance dictionaries Rouslan Korneychuk Python 8 02-10-2011 04:02 AM
Memory Layout for Multiple and Virtual Inheritance Ge Chunyuan C++ 0 07-23-2007 01:23 AM
Choosing Layout: Css-Layout or Table-Layout hpourfard@gmail.com ASP .Net 1 06-19-2006 10:06 AM
Article about memory layout for virtual inheritance Edsko de Vries C++ 0 01-09-2006 02:36 PM
inheritance and memory layout Anargyros L. Papadopoulos C++ 2 03-08-2005 02:18 PM



Advertisments