Does Unary + operator do type conversions?

后端 未结 4 652
眼角桃花
眼角桃花 2021-01-04 04:28

Till now I was believing that there is no use of unary + operator.

But then I came across with following example:

char ch;
short sh;
in         


        
4条回答
  •  情歌与酒
    2021-01-04 05:26

    Operator unary + triggers "initial" usual arithmeric conversions, so all integer operands, which type has lower rank than rank of int and unsigned int are promoted to int (or unsigned int if int type does not cover all values of type being promoted on that implementation).

提交回复
热议问题