> 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)
> {}

Try:

class CMyClass
{
public:

        enum DATASTORED
        {
           FIVEHUNDRED,
           ONEHUNDRED,
        };

        CMyClass();
        CMyClass(DATASTORED ds);

        const enum DATASTORED m_dataStored;
};

// .cpp:
CMyClass::CMyClass(CMyClass::DATASTORED ds) :
    m_dataStored(ds)
{}


-------------
Ehsan Akhgari

Farda Technology (http://www.farda-tech.com/)

List Owner: [EMAIL PROTECTED]

[ Email: [EMAIL PROTECTED] ]
[ WWW: http://www.beginthread.com/Ehsan ]

Light without eyes illuminates nothing.





Reply via email to