这个结果和我理解的好像有很大差距~~~~请哪位解释一下
感激不尽
#include<iostream>
using namespace std;
class aClass
{
private:
int a;
double b;
int c;
public:
aClass()
{
a=0;
b=0;
c=0;
}
int geta()
{
return a;
}
int getb()
{
return b;
}
int getc1()
{
return c;
}
};
class bClass
{
private:
int a1;
public:
bClass()
{
a1=0;
}
int geta1()
{
return a1;
}
};
void main()
{
aClass a;
aClass *p1=new aClass;
bClass b;
bClass *p2=new bClass;
cout<<sizeof(a)<<endl;
cout<<sizeof(int)<<endl;
cout<<sizeof(b)<<endl;
cout<<sizeof(double)<<endl;
system("pause");
}
结果
24
4
4
8
bClass的4很好理解,就一个int~~~可是aClass为何是24呢?