之前一直搞不清楚C++中各基本内置类型的字节数,今天运行了一下。C++基本内置类型一共十种,short,int,unsigned,long;bool;char,wchar_t;float,double,long double.与《C++primer》中不一样的一点是:在我的机器上long double也是8Byte,即64位。而书上说的是“long double 类型用三个或四个字(96位或128位)来表示”。
#include <iostream>
using namespace std;
int main()
{
cout<<"unsigned:"<< sizeof(unsigned)<<endl;//4
cout<<"int:"<< sizeof(int)<<endl;//4
cout&l......
阅读全文