C++????麯?????????????
???????????? ???????[ 2014/4/23 10:29:32 ] ????????C++ ?麯?? ????
????char?????????? ????????4???????? ???????????? ???4??????????(byte).
????GCC:
????GCC?У? ???????麯?????????У? ??????????洢???麯????(virtual function table)?? ???4?????.
??????л??л????????? ???麯????? ????л??????.
????????:
/*
* test.cpp
*
* Created on: 2014.04.20
* Author: Spike
*/
/*eclipse cdt?? gcc 4.8.1*/
#include <iostream>
using namespace std;
class A {
char k[5];
public:
virtual void aa() {};
};
class B : virtual public A {
char j[6];
public:
virtual void bb() {};
};
class C : virtual public B {
char i[7];
public:
virtual void cc() {};
};
int main() {
std::cout << "sizeof(A) = " << sizeof(A) << std::endl;
std::cout << "sizeof(B) = " << sizeof(B) << std::endl;
std::cout << "sizeof(C) = " << sizeof(C) << std::endl;
return 0;
}
???????:
????sizeof(A) = 12
????sizeof(B) = 24
????sizeof(C) = 36
????VS:
????VS?У? ????????£? ?????麯????д??????麯?????У? ????????????????麯????? ????????????麯????;
?????????????У? ???????? ????麯????????б?? ??????????8?????(??????);
???????:
??????
???·???
??????????????????
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