class and array of struct

M

Mosfet

Hi,

let's say I have a class defined like that :



..H
class CViewMgr
{
public:

enum ECreationMode
{
CREATE_ONCE = 0,
CREATE_AND_DESTROY,
};

struct stViewInfo
{
UINT iViewId;
ECreationMode eCreationMode;
UINT iSysViewId;
CView* pView;
};
};


I would like to create an array of stViewInfo structure.
So I did this :

..CPP:

CViewMgr::stViewInfo g_ViewInfo[] =
{
{ IDD_TESTSWITCHVIEW_FORM, CViewMgr::CREATE_ONCE,
AFX_IDW_PANE_FIRST, NULL },
{ IDD_WELCOME_VIEW, CViewMgr::CREATE_AND_DESTROY,
AFX_IDW_PANE_FIRST + 1, NULL },
{ IDD_OTHER_VIEW, CViewMgr::CREATE_AND_DESTROY, AFX_IDW_PANE_FIRST +
2, NULL },
};

and it works but from what I understand my g_ViewInfo is global while I
would like to restrict its scope to CViewMgr.

How can I do this ?




I would like something like CViewMgr::stViewInfo CViewMgr::g_ViewInfo[]=...
 
M

Markus Schoder

Mosfet said:
Hi,

let's say I have a class defined like that :



.H
class CViewMgr
{
public:

enum ECreationMode
{
CREATE_ONCE = 0,
CREATE_AND_DESTROY,
};

struct stViewInfo
{
UINT iViewId;
ECreationMode eCreationMode;
UINT iSysViewId;
CView* pView;
};
};


I would like to create an array of stViewInfo structure.
So I did this :

.CPP:

CViewMgr::stViewInfo g_ViewInfo[] =
{
{ IDD_TESTSWITCHVIEW_FORM, CViewMgr::CREATE_ONCE,
AFX_IDW_PANE_FIRST, NULL },
{ IDD_WELCOME_VIEW, CViewMgr::CREATE_AND_DESTROY,
AFX_IDW_PANE_FIRST + 1, NULL },
{ IDD_OTHER_VIEW, CViewMgr::CREATE_AND_DESTROY, AFX_IDW_PANE_FIRST +
2, NULL },
};

and it works but from what I understand my g_ViewInfo is global while I
would like to restrict its scope to CViewMgr.

How can I do this ?




I would like something like CViewMgr::stViewInfo CViewMgr::g_ViewInfo[]=...

Putting

static stViewInfo g_ViewInfo[];

in your class definition allows you to do exactly that.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,217
Latest member
topweb3twitterchannels

Latest Threads

Top