strchr函数用法_c++ strchr函数_strchr函数原型(28)

电脑杂谈  发布时间:2017-02-28 18:06:59  来源:网络整理

(1)、所有基类名应在80列限制下尽量与子类名放在同一行.

(2)、关键词public:,protected:,private:要缩进1个空格.

(3)、除第一个关键词(一般是public)外,其他关键词前要空一行.如果类比较小的话也可以不空.

(4)、这些关键词后不要保留空行.

(5)、public放在最前面,然后是protected,最后是private.

(6)、关于声明顺序的规则请参考声明顺序一节.

初始化列表:构造函数初始化列表放在同一行或按四格缩进并排几行.

下面两种初始化列表方式都可以接受:

// When it all fits on one line:
MyClass::MyClass(int var) : some_var_(var), some_other_var_(var + 1) {
或

// When it requires multiple lines, indent 4 spaces, putting the colon on
// the first initializer line:
MyClass::MyClass(int var)
    : some_var_(var),             // 4 space indent
      some_other_var_(var + 1) {  // lined up
  ...
  DoSomething();
  ...
}
名字空间格式化:名字空间内容不缩进.

名字空间不要增加额外的缩进层次,例如:

namespace {

void foo() {  // Correct.  No extra indentation within namespace.
  ...
}

}  // namespace
不要缩进名字空间:Warning:

namespace {

  // Wrong.  Indented when it should not be.
  void foo() {
    ...
  }

}  // namespace
水平留白:水平留白的使用因地制宜.永远不要在行尾添加没意义的留白.

常规:

循环和条件语句:

if (b) {          // Space after the keyword in conditions and loops.
} else {          // Spaces around else.
}
while (test) {}   // There is usually no space inside parentheses.
switch (i) {
for (int i = 0; i < 5; ++i) {
switch ( i ) {    // Loops and conditions may have spaces inside
if ( test ) {     // parentheses, but this is rare.  Be consistent.
for ( int i = 0; i < 5; ++i ) {
for ( ; i < 5 ; ++i) {  // For loops always have a space after the
  ...                   // semicolon, and may have a space before the
                        // semicolon.
switch (i) {
  case 1:         // No space before colon in a switch case.
    ...
  case 2: break;  // Use a space after a colon if there's code after it.
操作符:


本文来自电脑杂谈,转载请注明本文网址:
https://www.pc-fly.com/a/jisuanjixue/article-35033-28.html

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    热点图片
    拼命载入中...