C++核心准则​NL.20:不要在同一行上放置两个语句

2020-12-15 15:01:14 浏览数 (1)

NL.20: Don't place two statements on the same line

NL.20:不要在同一行上放置两个语句

Reason(原因)

Readability. It is really easy to overlook a statement when there is more on a line.

可读性。当一行上有更多语句时,很容易忽略某条语句。

Example(示例)

代码语言:javascript复制
int x = 7; char* p = 29;    // don't
int x = 7; f(x);    x;      // don't
Enforcement(实施建议)

Easy.

原文链接

https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#nl20-dont-place-two-statements-on-the-same-line

0 人点赞