C++???????????
???????????? ???????[ 2016/7/1 10:50:04 ] ????????.NET ??????????? ???
???????????????????????????
????????????virtual?????????????????vTable??
?????????(???????????)????????????????vTable?????vTables??
??????????λ???????????????????У????????????????????????ο?
??????????????????????????????Animal??Cow??Pig??Donkey?????????????????????????????????????makeSound()??walk()????????????????4????????????vTable???С????8???????????
?????????????м????????????????????????Cow??Pig??Donkey??д??makeSound()?????????????дwalk()??????????????makeSound()????????jump?????????code Address????????walk()??????jump??Animal????walk??Code Address??
?????????
??????????????????????????????????????????????????????????????????????????????????????????????(vPointer)??
??????????????????????????????????????????????С?4???????????????Donkey????????????????????£?
???????????main?????????????£?
int main(int argc?? const char * argv[])
{
int count = 2;
while (count --) {
Animal *animal = new Donkey;
animal->makeSound();
delete animal;
}
return 0;
}
???????????????????????Donkey????????н?????£?
?????????
?????????
????Program ended with exit code: 0
???????????????????????????????????????????
?????????????????????????????
??????
???·???
??????????????????
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