Is this legal?

R

red floyd

class A {
public:
enum E { EN1, EN2, EN3 };
};

class B {
public:
void f(const char *s, A::E en = A::E::EN1);
};

MSVC 7.1 accepts it, G++ 3.2.2 (3.2.2-3mdk) gives the following error:
`A::E' is not an aggregate type

Is this an error in G++ or in VC? What does the Holy Standard say?
 
R

red floyd

red said:
class A {
public:
enum E { EN1, EN2, EN3 };
};

class B {
public:
void f(const char *s, A::E en = A::E::EN1);
};

MSVC 7.1 accepts it, G++ 3.2.2 (3.2.2-3mdk) gives the following error:
`A::E' is not an aggregate type

Is this an error in G++ or in VC? What does the Holy Standard say?

Oops. The error is in reference to the A::E::EN1 default parameter value.
 
V

Victor Bazarov

red said:
Oops. The error is in reference to the A::E::EN1 default parameter value.

Enumerators are names in the same scope where the enumeration type
is declared. I.e. to get to EN1, you say A::EN1, not A::E::EN1.

Victor
 
R

red floyd

Victor said:
red said:
[enumeration scope question redacted]
Enumerators are names in the same scope where the enumeration type
is declared. I.e. to get to EN1, you say A::EN1, not A::E::EN1.

Victor

Thanks, Victor. Appreciate the help.
 

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

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top