class B {
public:
int b1;
int b2;
};
class D : public B {
public:
int d1;
int d2;
};
D *d = new D ();
d->d1 = 9032;
d->d2 = 3293;
d->b1 = 2948;
d->b2 = 8432;
B *b = d;
int x1 = b->b1;
int x2 = b->b2;
|
|
movq -8(%rbp), %rax
movl $9032, 8(%rax)
movq -8(%rbp), %rax
movl $3293, 12(%rax)
movq -8(%rbp), %rax
movl $2948, (%rax)
movq -8(%rbp), %rax
movl $8432, 4(%rax)
; B *b = d;
movq -8(%rbp), %rax
movq %rax, -16(%rbp)
; int x1 = b->b1;
movq -16(%rbp), %rax
movl (%rax), %eax
movl %eax, -20(%rbp)
; int x2 = b->b2;
movq -16(%rbp), %rax
movl 4(%rax), %eax
movl %eax, -24(%ebp)
|
|
Layout of Stack
|
Offset
|
Contents
|
-8(%rbp)
|
local variable D *d
|
-16(%rbp)
|
local variable B *b
|
-20(%rbp)
|
local variable int x1
|
-24(%rbp)
|
local variable int x2
|
Layout of Instance of D
|
Offset
|
Name
|
Contents
|
12 | d2 | 3293 |
8 | d1 | 9032 |
4 | b2 | 8432 |
0 | b1 | 2948 |
|