return (a) vs. return a

前端 未结 3 1568
被撕碎了的回忆
被撕碎了的回忆 2020-12-19 02:10

I have seen both in the C and C++ code I have been looking at.

What is the difference?

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-19 02:40

    return is not a function.

    It is more a point of style. I personally do not use parentheses in a return statement unless it is showing order of operations.

    examples

    return a;
    return (a || b);
    return (a && (b || c));
    return (a ? b : c);
    

提交回复
热议问题