Difference between += and =+ in C++

前端 未结 4 1386
栀梦
栀梦 2020-12-11 16:15

While programming in C++, I often confuse both \"+=\" and \"=+\", the former being the operator I actually mean. Visual Studio seems to accept both, yet they behave differen

4条回答
  •  臣服心动
    2020-12-11 16:28

    if you see = the first , it means you re-declare your variable value , but if you face + the first it means that you order the compiler to increment the value of the variable , keep it in you mind

    int x=20 ;
    x=+10 ;
    cout<< x <

提交回复
热议问题