Could you tell me something about 'static'?

Sep 5, 2009 at 6:30am
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// A program based single document
// CMainFrame.CPP

IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)

BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
ON_WM_CREATE()
END_MESSAGE_MAP()

static UINT indicators[] =
{
        ID_SEPARATOR,          // status line indicator
        ID_INDICATOR_CAPS,
        ID_INDICATOR_NUM,
        ID_INDICATOR_SCRL,
};

If I mask keyword 'static', there is no impact.
What is rationale about the keyword of 'static' be added here?
Sep 5, 2009 at 6:39am
IIRC, static when applied to globals limits their scope only to the .cpp they're defined in, so if a different file tried to use indicators, it would fail.
Sep 8, 2009 at 1:53pm
I see, Thanks!
Topic archived. No new replies allowed.