CppCoreGuidelines C.7 不要定义类和枚举的同时声明变量
29 July 2022
C.7: Don’t define a class or enum and declare a variable of its type
in the same statement
理由
类型的定义和变量的声明放在一起容易令人费解。这种处理也没什么必要性。
例子
struct Data { /*...*/ } data{ /*...*/ };
例子
struct Data { /*...*/ }; Data data{ /*...*/ };
强化
- 标记警告:类和枚举定义结尾处的
}后面不是; - 标记警告:类和枚举定义结尾处的
}后面的;忘写了