1,072
edits
m (→Formatting) |
|||
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 ==== |
edits