2013???????????--???е??????????
???????????? ???????[ 2013/1/18 10:46:21 ] ????????????
?????????class B???С??12bytes
???????????
class A
{
int a;
};
class B
{
int b;
};
class C
{
};
class D
{
};
class E: public virtual A ?? public virtual B ?? public virtual C ?? public virtual D
{
};
void main()
{
cout<<"sizeof E: "<<sizeof(E)<<endl; //
}
????Class?????????????virtual base class subobjects????????????????:????????????????????.???????е??????????????????????????й????offset(??object????????)????????????????????????????????????????????????virtual base class subobject?????????????????λ????????ε????????????б仯?????????????????????????????????????????????????????????????????????????????????derived class?????????????????乲?????.????????м?????????????:?????????Class???????????????????????????????????沼???
?????????????????????
????class E???С??????е?????????????????
cl test.cpp /d1reportSingleClassLayoutE
?????????????????????????classE????????У???????????е????????????????????????????????Сint a??b ??????8 bytes??????????????VC++????????????麯???????С??????У?????????????и???????????????????
E::$vbtable@:
1> 0 | 0
1> 1 | 4 (Ed(E+0)A)
1> 2 | 8 (Ed(E+0)B)
1> 3 | 12 (Ed(E+0)C)
1> 4 | 16 (Ed(E+0)D)
??????????vbtable??????????棬????vbtable(virtual base class table)??????????????????????м????vbtable??????????4???E??vbtable???????A?????????????????8??12??16????????????????????????vbtable???????????????????????E?????????л????????????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11