compile error with templates in gcc 4.0.1 on Mac OSX 10.4

M

musikit

I have my own templated vector class and im trying to use my vector
class in another templated class. im using GCC 4.0.1 on Mac OSX (if i
need to upgrade that isnt a problem) but i want to know if this is a
misunderstanding on my part or a compiler issue, or there is a work
arround without requiring a compiler upgrade.

my vector looks like

template<typename T> class MyVector
{
private:
//data
public:
class iterator
{
//decl
}

};

the class im trying to use it in looks like

template<typename T> class MyVectorUser
{
private:
MyVector<T *> list;
void dosomething()
{
for(MyVector<T *>::iterator i = list.begin() ; i !=
list.end() ; i++)
{
//code
}
}

};

the way im using the MyVectorUser is like this

struct MyData
{
int x;

};

MyVectorUser<MyData> data;

however i get a compile error from GCC "error: expected `;' before
'i'"

can anyone please give me some insight?
 
K

Kai-Uwe Bux

I have my own templated vector class and im trying to use my vector
class in another templated class. im using GCC 4.0.1 on Mac OSX (if i
need to upgrade that isnt a problem) but i want to know if this is a
misunderstanding on my part or a compiler issue, or there is a work
arround without requiring a compiler upgrade.

my vector looks like

template<typename T> class MyVector
{
private:
//data
public:
class iterator
{
//decl
}

};

};

the class im trying to use it in looks like

template<typename T> class MyVectorUser
{
private:
MyVector<T *> list;
void dosomething()
{
for(MyVector<T *>::iterator i = list.begin() ; i !=
list.end() ; i++)

{
//code
}
}

};

the way im using the MyVectorUser is like this

struct MyData
{
int x;

};

MyVectorUser<MyData> data;

however i get a compile error from GCC "error: expected `;' before
'i'"

can anyone please give me some insight?


Best

Kai-Uwe Bux
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top