Synopsis: | Variables and types are to be declared with the smallest possible scope |
Language: | C++ |
Severity Level: | 9 |
Category: | Object Life Cycle |
Description: |
Not only variables must be declared with the smallest possible scope. This also applies to types, structures, enumerations, constants, classes etc.. For example, if an enumeration is used for a return value of a member function, the enumeration is defined in the scope of the class. class CMyClass { public: enum MyReturnValue { MYRETURNVALUE_1, MYRETURNVALUE_2, }; MyReturnValue Foo(); }; |