相关疑难解决方法(0)

为什么在C和C++中算术运算之前必须将short转换为int?

从我从得到的回答这个问题,看来C++继承了这一要求,对于转换shortint从C.执行算术运算时,我可以挑你的大脑,以为什么这是用C首先介绍?为什么不做这些操作short呢?

例如(取自评论中的dyp建议):

short s = 1, t = 2 ;
auto  x = s + t ;
Run Code Online (Sandbox Code Playgroud)

x将具有int类型.

c c++ int short integer-promotion

70
推荐指数
4
解决办法
8650
查看次数

标签 统计

c ×1

c++ ×1

int ×1

integer-promotion ×1

short ×1