小编Wil*_*ill的帖子

在C ++中将运算符'+'和'*'用于语句

在C ++中,当我运行以下代码时:

void main()
{
  2;
  +
  3;
}
Run Code Online (Sandbox Code Playgroud)

没有错误,但是当我运行此代码时:

void main()
{
  2;
  *
  3;
}
Run Code Online (Sandbox Code Playgroud)

有这个错误:

main.cpp:5:3: error: invalid type argument of unary ‘*’ (have ‘int’)
    5 |   3;
      |   ^
Run Code Online (Sandbox Code Playgroud)

请有人解释一下谢谢

c++ operators unary-operator

-4
推荐指数
1
解决办法
109
查看次数

标签 统计

c++ ×1

operators ×1

unary-operator ×1