HI

You can only do that if the enum is only used from inside the class.  If you
call a class member from another class that needs the enum you must declare
it outside the class.

Max


----- Original Message ----- 
From: "Palmer, Jean L." <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, April 20, 2004 7:48 PM
Subject: [msvc] const enum data member


> I would like to declare an enum at class scope, and use that enum as the
type of a const class member.  I've tried different ways to do it, moved the
order around, etc. but I can't get it to compile.  Is there a way to do
this?
> simplified example:
>
> // .h:
> class CMyClass
> {
> public:
>
> CMyClass();
> CMyClass(DATASTORED ds); // error C2629: unexpected 'class CMyClass ('
>                                // error C2238: unexpected token(s)
preceding ';'
>
> enum DATASTORED
> {
>    FIVEHUNDRED,
>    ONEHUNDRED,
> };
>
> const DATASTORED m_dataStored;
> }
>
> // .cpp:
> CMyClass::CMyClass(DATASTORED ds) :
>     m_dataStored(ds)
> {}
>
>
>
> ===========
> Jean Palmer
> Northrop Grumman
> > - [EMAIL PROTECTED]
> > ( (410-993-2627)
> >
> >
>
> _______________________________________________
> msvc mailing list
> [EMAIL PROTECTED]
> See http://beginthread.com/mailman/listinfo/msvc_beginthread.com for
subscription changes, and list archive.
>
>



Reply via email to