What's the purpose of using braces (i.e. {}) for a single-line if or loop?

前端 未结 23 1429
独厮守ぢ
独厮守ぢ 2020-11-28 00:33

I\'m reading some lecture notes of my C++ lecturer and he wrote the following:

  1. Use Indentation // OK
  2. Never rely on operator preced
23条回答
  •  鱼传尺愫
    2020-11-28 01:25

    If you are a compiler, it doesn't make any difference. Both are the same.

    But for programmers, the first one is more clear, easy to read and less error-prone.

提交回复
热议问题