enum and classes

G

Gaijinco

How come that this is legal:

class A
{
enum Enum{B,C};
Enum foo()
{
return B;
}
};

But this isn't:

class A
{
enum Enum{B,C};
Enum foo();
};

Enum A::foo()
{
return B;
}
 
R

red floyd

Gaijinco said:
How come that this is legal:

class A
{
enum Enum{B,C};
Enum foo()
{
return B;
}
};

But this isn't:

class A
{
enum Enum{B,C};
Enum foo();
};

Enum A::foo()
Enum is not in scope.

A::Enum A::foo()
 
Z

zeppe

Gaijinco said:
How come that this is legal:

class A
{
enum Enum{B,C};
Enum foo()
{
return B;
}
};

But this isn't:

class A
{
enum Enum{B,C};
Enum foo();
};

Enum A::foo()
{
return B;
}

If you define the function outside of the scope of A, the symbol Enum
doesn't mean anything anymore by itself. You have to write

A::Enum A::foo()
{
return B;
}


regards,

Zeppe
 
M

marcosrijo

If you define the function outside of the scope of A, the symbol Enum
doesn't mean anything anymore by itself. You have to write

A::Enum A::foo()
{
return B;

}

regards,

Zeppe

hello
 
M

marcosrijo

If you define the function outside of the scope of A, the symbol Enum
doesn't mean anything anymore by itself. You have to write

A::Enum A::foo()
{
return B;

}

regards,

Zeppe

hello
 

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,999
Messages
2,570,246
Members
46,840
Latest member
BrendanG78

Latest Threads

Top