????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?????(??????);
???????: