自考新教材-p253
多态机制下对象存储空间的大小
源程序:
#include <iostream>
using namespace std;
class A {
public:
int i;
virtual void func();
virtual void func2();
};
class B :public A {
int j;
void func() {}
};
int main() {
cout << sizeof(A) << "," << sizeof(B);
system("pause");
return 0;
}
运行结果: