1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
class Base 
    ... 
};
 
class Derived: public Base 
    ... 
};
 
 
int main()
{
    Derived d;
    Base *pb = &d;
}



이건 객체 d의 this포인터에서 Base 오프셋 주소 넘겨주는거고



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
class Base 
    ... 
};
 
class Derived: public Base 
    ... 
};
 
 
int main()
{
    Derived* d = new Derived;
    Base *pb = static_cast<Base*>(d);
}



이건 위 코드랑 같이 offset 주소 찾는거 까진 맞는데 

해당 offset 주소 기점으로 힙 새로 할당해서 this로 넘겨주는거냐