数据类型所占用内存的大小
数据类型所占的大小是由编译器和你电脑的架构共同决定的。
举个例子: 定义一个int x=0;
那么怎么去查看到底这个int型的x变量占用的内存大小呢?
c++中提供了sizeof这个函数。
我们可以打印sizeof(x)去验证,我的电脑上,Visual Studio2013环境中,x变量占用4个bytes。
You may be surprised to find that the size of a given data type is dependent on the compiler and/or the computer architectureint!

浙公网安备 33010602011771号