473,385 Members | 1,927 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Memory layout of an object with multiple inheritance

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.

Oct 8 '06 #1
1 3155
st******@gmail.com 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

Oct 8 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Bryan Parkoff | last post by:
I have C++ Primer Third Edition -- Author Stanley B. Lippman and Josee Lajoie. I have been studying it for couple months however it does not provide a valuable information which it is about...
1
by: ankit.ankit | last post by:
Referring to the following links. 1....
22
by: Matthew Louden | last post by:
I want to know why C# doesnt support multiple inheritance? But why we can inherit multiple interfaces instead? I know this is the rule, but I dont understand why. Can anyone give me some concrete...
8
by: Raterus | last post by:
Hi, I don't even know if this can be done.. Lets say I have two objects, --- Public Class Employee End Class
0
by: Edsko de Vries | last post by:
Hi, I wrote an article that may be of interest to some people in this newsgroup. It explains the memory (object) layout for multiple and virtual inheritance. The article can be read at ...
14
by: Anoop | last post by:
Hi, I am new to this newsgroup and need help in the following questions. 1. I am workin' on a GUI application. Does C# provides Layout Managers the way Java does to design GUI? I know that it...
0
by: Ge Chunyuan | last post by:
hi: Just out of curiosity, more than 10 years passed since Stanley B. Lippman's <<Inside the C++ Object Model>>. Is there anything changed these days? Eg, the "Memory Layout for Multiple...
3
by: Peskov Dmitry | last post by:
Hi, What is the memory layout of an object, and the derived object. For example : class A { private: int prv_data; protected: int pro_data;
3
by: Rahul | last post by:
While reading Inside the C++ object model I came through the following paragraph Point3d origin, *ptr = &origin; A) origin.x = 0.0; B) ptr->x = 0.0; The book says "A & B statements performs...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.