enums and namespaces

V

Vincent RICHOMME

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 ?
 
I

Ivan Vecerina

: 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
 

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

Similar Threads

Fixing "typos" in enums... 18
forward declaration and enums 0
Enums 17
enums and scope 5
enums 6
enums clash 9
Classes for enums 5
Namespaces and declarations 1

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top