- ImageButton , Button, ImageControl. ImageButton , :
ImageButton / :
ImageButton ib(OK, ok.png);
Button * pButton = & ib;
ImageControl * pControl = & ib;
ImageButton, pButton pControl . . , pButton . . , .
, . . , , :
ImageButton * pIB1 = (ImageButton *) pButton;
ImageButton * pIB2 = (ImageButton *) pControl;
, .
, , . , 2 vptr - . , ( ).
, , , this .
, , , Release ( inline, ):
, .. vptr .
|
|
Derived::f2? , Derived::f2 this .
- this , ? , . , . , , .. f2.
Base2 * pB = pD;
pB->f2();
, , , , . , VTABLE, this pB. , 8 !
? . Derived::f2 , - Derived, Base2. , this , / . , , . , , - this.
, , . .
:
Int main ()
{
Derived d;
d.Base1::f();
d.Base2::f();
}
using-:
Class Derived
: public Base1, public Base2
{
public:
using Base2::f;
};
Int main ()
{
Derived d;
d.f(); // Base2::f
}
, , . this 4 .
, this , . , Derived::f , . , . , Derived::f. , f Base1, this , f Base2, 4 .
|
|
this , , thunk (- ). , this . , thunk pBase2->f(). , , - sub this, ecx 4 , jmp :
[thunk]:Derived::f`adjustor{4}':
D1CB0 sub ecx,4
013D1CB3 jmp Derived::f (13B38D4h)
this, , , .