什么是用C一元“+”操作符的目的是什么? [英] What is the purpose of the unary '+' operator in C?
本文介绍了什么是用C一元“+”操作符的目的是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在C,是合法的写类似:
In C, it's legal to write something like:
int foo = +4;
不过,据我所知道的,一元 +
在 +4
是一个空操作。是吗?
However, as far as I can tell, the unary +
in +4
is a no-op. Is it?
推荐答案
由于按照C90标准:
一元+运算符的结果就是它的操作数的价值。积分促销
操作数执行。其结果具有推广的类型。
The result of the unary + operator is the value of its operand. The integral promotion is performed on the operand. and the result has the promoted type.
和
的操作数一元+或 - 操作员应算术类型 ..
The operand of the unary + or - operator shall have arithmetic type..
这篇关于什么是用C一元“+”操作符的目的是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文