473,385 Members | 1,468 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

compile error with templates in gcc 4.0.1 on Mac OSX 10.4

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 Tclass MyVector
{
private:
//data
public:
class iterator
{
//decl
}

};

the class im trying to use it in looks like

template<typename Tclass 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<MyDatadata;

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

can anyone please give me some insight?
Jun 27 '08 #1
2 1538
mu*****@gmail.com wrote:
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 Tclass MyVector
{
private:
//data
public:
class iterator
{
//decl
}
};

};

the class im trying to use it in looks like

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

{
//code
}
}

};

the way im using the MyVectorUser is like this

struct MyData
{
int x;

};

MyVectorUser<MyDatadata;

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

can anyone please give me some insight?

Best

Kai-Uwe Bux
Jun 27 '08 #2
On Jun 4, 12:24 pm, Kai-Uwe Bux <jkherci...@gmx.netwrote:
musi...@gmail.com wrote:
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 Tclass MyVector
{
private:
//data
public:
class iterator
{
//decl
}

};
};
the class im trying to use it in looks like
template<typename Tclass MyVectorUser
{
private:
MyVector<T *list;
void dosomething()
{
for(MyVector<T *>::iterator i = list.begin() ; i !=
list.end() ; i++)

typename MyVector<T*>::iterator
{
//code
}
}
};
the way im using the MyVectorUser is like this
struct MyData
{
int x;
};
MyVectorUser<MyDatadata;
however i get a compile error from GCC "error: expected `;' before
'i'"
can anyone please give me some insight?

Best

Kai-Uwe Bux
thank you very much for your help.
Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Ben Ingram | last post by:
Hi all, I am writing a template matrix class in which the template parameters are the number of rows and number of columns. There are a number of reasons why this is an appropriate tradeoff for...
1
by: Amit | last post by:
Greetings. I am looking through some of the examples in Stroustrup's book and he has certain examples of doing compile time checks for a variety of things. One of them being the following... ...
4
by: andrewcw | last post by:
I am moving some code forward from .NET 1.1. I was able to load the XSL file and perform the transform. The MSDN documentation looks like it should be easy. But I get a compile error. Ideas ?...
16
by: desktop | last post by:
I have read that using templates makes types know at compile time and using inheritance the types are first decided at runtime. The use of pointers and casts also indicates that the types will...
7
by: QiongZ | last post by:
Hi, I just recently started studying C++ and basically copied an example in the textbook into VS2008, but it doesn't compile. I tried to modify the code by eliminating all the templates then it...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.