Errors with enums

K

Kaba

Consider the following code:

template <typename T>
class A
{
public:
class Direction
{
public:
enum Enum
{
Left, Right
};
};

void f()
{
Direction::Enum a = Direction::Left;
}
};

int main()
{
return 0;
}

Comeau and GCC (4.4.5) give a similar error:

"In member function ?void A<T>::f()?:
error: expected ?;? before ?a?"

Visual Studio 2008 compiles fine.

If the 'template <typename T>' is removed, then Comeau and Visual Studio
2008 compile it, while GCC gives:

/tmp/ccHbZ8no_O:(.eh_frame+0x12): undefined reference to
`__gxx_personality_v0'
collect2: ld returned 1 exit status

Explanations for the behaviours?
 
I

Ian Collins

Consider the following code:

template<typename T>
class A
{
public:
class Direction
{
public:
enum Enum
{
Left, Right
};
};

void f()
{
Direction::Enum a = Direction::Left;

typename Direction::Enum a = Direction::Left;
 

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

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,740
Latest member
AdolphBig6

Latest Threads

Top