C++ style guide: Difference between revisions

Jump to navigation Jump to search
441 bytes added ,  20 December 2023
m
Line 64: Line 64:


If you have nested {{codeline|if}} statements, use extra braces for extra clarification.
If you have nested {{codeline|if}} statements, use extra braces for extra clarification.
==== Switch statements ====
Indent ''both'' the curly braces and the body of the switch statement (so that the body gets indented by ''two'' indents).
However, the {{codeline:case}} statement is not doubly indented and instead aligns with the first brace.
<syntaxhighlight lang="cpp">
switch (info)
  {
  case -1:
    {
      cout << "function failed\n";
      return false;
    }
  case 0:
    return true;
  }
</syntaxhighlight>   


==== Split long expressions ====
==== Split long expressions ====
1,072

edits

Navigation menu