您的位置:首页 > 其它

关于类得数据成员的大小问题。求解。

2011-03-31 22:43 239 查看
Code:

# include<iostream>

using namespace std;

class A{

public :

int b;

void test()

{

int j;

}

private:

char c;

int a;

};

int main()

{

cout<<sizeof(A)<<endl;

}



为什么是8啊,把char c注释掉结果是4,把int a 注释掉结果是1.但是为什么在一起就是8了。不明白清前辈指教!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐