C++ sizeof(结构)。。。给出错误的结果,VS 2010 struct测试{ 国际年; 字符文本; 双数; }; int main() { 试验t; cout
C++可能会在成员之间添加填充。因此,结构可能大于其成员的添加大小。C++ sizeof(结构)。。。给出错误的结果,VS 2010 struct测试{ 国际年; 字符文本; 双数; }; int main() { 试验t; cout,c++,structure,sizeof,C++,Structure,Sizeof,C++可能会在成员之间添加填充。因此,结构可能大于其成员的添加大小。double将以mem-aligned(字大小)存储。如果编译器给出的答案与您期望的不符,则通常不是编译器出错。 struct test{ int year; char text; double num; }; int main () { test t; cout<<sizeof(t); return 0; }
double
将以mem-aligned(字大小)存储。如果编译器给出的答案与您期望的不符,则通常不是编译器出错。
struct test{
int year;
char text;
double num;
};
int main ()
{
test t;
cout<<sizeof(t);
return 0;
}