BS, directly on the code
#include<iostream>
using namespace std;
class A{
};
class B{
B(){}
~B(){}
};
class C{
C(){}
virtual ~C(){}
};
int main(){
cout<<"A的大小:"<<sizeof(A)<<endl;
cout<<"B的大小:"<<sizeof(B)<<endl;
cout<<"C的大小:"<<sizeof(C)<<endl;
}
what's the result?
The following is to prove safety of the explanation OFFER:
Explain in great detail.
My machine is 64, so the result is:
expand:
If a class has both a virtual function?
class D{
D(){}
virtual ~D(){}
virtual void func(){}
};
And as a result a virtual function, or 64.
Because sizeof size class with a virtual function, and the number of virtual functions in fact not relevant, is associated virtual function pointers.