转贴:当sizeof()中的参数是类对象时是什么意思?
#include<iostream>
using namespace std;
class A
{
public:
A(){cout<<"A::A()";}
~A(){cout<<"A::~A()";}
};
class B
{
public:
B(){cout<<"B::B()";}
~B(){cout<<"B::~B()";}
};
class D:public B
{
protected:
A a;
public:
D(){cout<<"D::D()";}
~D(){cout<<"D::~D()";}
};
int main()
{
D d;
cout<<sizeof(d)<<endl;//这个sizeof(d)是什么意思啊?
return 0;
}