
The overhead normally stores the pointer to the object address in the heap. In addition to other information included by the implementing framework. It is highly dependent on the target platform, so theoretically you can leave it out and that accounts for differences when you run sizeof(MyClassbject) and when you manually calculate the class size based on its data. When optimizing your code for low memory footprint usage its valuable knowledge knowing how manually determine how much memory your object will take by simply looking at the code. ----- Original Message ----- | From: "Josh Handley" <josh@bridgeinternationalacademies.com> | To: skunkworks@lists.my.co.ke | Sent: Monday, November 28, 2011 11:54:50 AM | Subject: [Skunkworks] Size of an object in memory at runtime | | Actually the const should be dealt with at compile time and not cost | any | memory. A static variable on the other hand would be stored in | memory | although only one copy for all instances of the class as you | mentioned. | | In the C++ implementations I have seen the only overhead for each | object | instance above the memory used by the member variables is a single | pointer for the vtable (virtual function table). This would not | apply | to the class in your example since it has no virtual functions. I | don't | think that this is required by the standard so different compilers | will | handle it differently but this is definitely what Visual C++ does. | | Josh | | | _______________________________________________ | Skunkworks mailing list | Skunkworks@lists.my.co.ke