enums and namespaces

Discussion in 'C++' started by Vincent RICHOMME, Nov 11, 2006.

  1. Hi,

    some questions about namespaces.
    Let's say I have a class CExtPaintManager defined like this :



    class CExtPaintManager
    {
    protected:
    ....

    class B
    {

    };
    public:
    class C
    {

    };

    enum e_align_t
    {
    __ALIGN_HORIZ_CENTER = 1,
    __ALIGN_HORIZ_RIGHT = 2,
    __ALIGN_VERT = 4
    };

    };

    When I compile my sample code compiler says :
    warning C4482: nonstandard extension used: enum
    'CExtPaintManager::e_align_t' used in qualified name

    m_nAlign = CExtPaintManager::e_align_t::__ALIGN_HORIZ_CENTER
    |CExtPaintManager::e_align_t::__ALIGN_VERT;
    What does it mean and how fix it ?
    Vincent RICHOMME, Nov 11, 2006
    #1
    1. Advertising

  2. "Vincent RICHOMME" <> wrote in message
    news:4555d387$0$14544$...
    : class CExtPaintManager
    : {
    ....
    :
    : enum e_align_t
    : {
    : __ALIGN_HORIZ_CENTER = 1,
    : __ALIGN_HORIZ_RIGHT = 2,
    : __ALIGN_VERT = 4
    : };
    :
    : };
    :
    : When I compile my sample code compiler says :
    : warning C4482: nonstandard extension used: enum
    : 'CExtPaintManager::e_align_t' used in qualified name
    :
    : m_nAlign = CExtPaintManager::e_align_t::__ALIGN_HORIZ_CENTER
    : |CExtPaintManager::e_align_t::__ALIGN_VERT;
    : What does it mean and how fix it ?

    In standard C++, enumeration constants are accessible
    within the scope that contains the enum. The enum itself
    does not define a scope. So you should write:
    m_nAlign = CExtPaintManager::__ALIGN_HORIZ_CENTER
    | CExtPaintManager::__ALIGN_VERT;

    Another issue in the code example you posted is that
    it is illegal for a standard-conformant C++ program
    to use identifiers that contain two underscores,
    or to use (most) identifiers that start with an underscore.


    -Ivan
    --
    http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form
    Ivan Vecerina, Nov 11, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mr Newbie
    Replies:
    10
    Views:
    754
    Mr Newbie
    Nov 22, 2005
  2. Replies:
    0
    Views:
    1,464
  3. Simon Elliott

    enums in C and C++

    Simon Elliott, Oct 28, 2004, in forum: C++
    Replies:
    13
    Views:
    18,469
    Simon Elliott
    Nov 1, 2004
  4. =?utf-8?b?QXNiasO4cm4gU8OmYsO4?=

    Enums without identifier, enums and typedef

    =?utf-8?b?QXNiasO4cm4gU8OmYsO4?=, Jan 19, 2007, in forum: C Programming
    Replies:
    10
    Views:
    1,093
    Keith Thompson
    Jan 20, 2007
  5. Jason Kraftcheck

    enums and bitfileds and signs

    Jason Kraftcheck, Nov 15, 2007, in forum: C++
    Replies:
    2
    Views:
    405
    James Kanze
    Nov 16, 2007
Loading...

Share This Page