多态机制下对象存储空间的大小
源程序:
#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;
}
运行结果:
原文地址:https://www.cnblogs.com/duanqibo/p/12181927.html
时间: 2024-10-10 22:42:51