【发布时间】:2010-09-17 12:43:36
【问题描述】:
非常基本的问题:如何在 C++ 中编写 short 文字?
我知道以下几点:
-
2是int -
2U是unsigned int -
2L是long -
2LL是long long -
2.0f是float -
2.0是double -
'\2'是char。
但是我将如何编写 short 文字?我尝试了2S,但这给出了编译器警告。
【问题讨论】:
-
我猜不支持短文字仅仅是因为在评估期间任何小于 int 的东西都会被“提升”为 int 。 int 具有最自然的大小。这在 C++ 中称为整数提升。