考虑到以下语句返回4
,C++中的int
和long
类型有什么区别?
Considering that the following statements return 4
, what is the difference between the int
and long
types in C++?
sizeof(int)
sizeof(long)
来自 this 参考:
一个 int 最初的目的是的自然"字大小处理器.许多现代处理器可以以相等的方式处理不同的字长轻松.
An int was originally intended to be the "natural" word size of the processor. Many modern processors can handle different word sizes with equal ease.
还有这一点:
在许多(但不是全部)C 和 C++ 上实现,一个长大于一个整数.当今最流行的桌面平台,如 Windows 和 Linux,主要在 32 位处理器上运行,并且这些平台的大多数编译器使用具有相同大小的 32 位 int并表示为 long.
On many (but not all) C and C++ implementations, a long is larger than an int. Today's most popular desktop platforms, such as Windows and Linux, run primarily on 32 bit processors and most compilers for these platforms use a 32 bit int which has the same size and representation as a long.
这篇关于long 和 int 数据类型的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!