TICS Coding Standard Viewer 
TIOBE Software Quality Framework
Print-friendly version
©TIOBE Software www.tiobe.com
 
C++ Coding Standard
Search

Rule:  OLC#006Checked automatically with code checker

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();
};


Literature References:
Ellemtel Rule 38, adapted.
ISC++ Rec. 5.1