今天突然想不起来c++64位机上各个基础类型占用的字节空间,用程序输出了一下,记下来:
int main()
{
int a;
char b;
float c;
double d;
string e;
bool f;
cout << "int :" << sizeof(a) << endl;
cout << "char :" << sizeof(b) << endl;
cout << "float :" << sizeof(c) << endl;
cout << "double :" << sizeof(d) << endl;
cout << "string :" << sizeof(e) << endl;
cout << "bool :" << sizeof(f) << endl;
return 0;
}
输出结果为