I don't know for sure, but if you consider class as struct:
class A's objects will have size of 4 bytes (only an integer)
B's - 8 bytes (only a double)
C's: derive from A and B, so it will have at least 4+8 or 8+4 = 12+ bytes
depends on your declaration the structure of a C's object will be
1 2 3 4 5
|
0 1 2 3 4 5 6 7 8 9 10 11
[A][ ][ ][ ] [B][ ][ ][ ][ ][ ][ ][ ] ... (case 1)
or
0 1 2 3 4 5 6 7 8 9 10 11
[B][ ][ ][ ][ ][ ][ ][ ] [A][ ][ ][ ] ... (case 2)
|
so a class A pointer point at C will point at either 0 (case 1) or 8 (case 2)
and class B pointer point at C will point at either 4(case 1) or 0 (case 2)
and for calling class A methods from *b1, the compiler will use 4 bytes of d after b1, calling class B methods from *b2, the compiler will use 8 bytes of d after b2, calling an override method of class C will use all bytes of d.
I guess your case should be case 1, because you declare public A, public B, so A first B second, 4+8, pointer b1 and b2 should be different by 4, not 8 :/
My output:
0xbf60e0ac
0xbf60e0ac
0xbf60e0b0 |
b1 and b2 is different by 4