By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,440 Members | 1,411 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,440 IT Pros & Developers. It's quick & easy.

problem declaring vector iterator in class template

P: n/a
Can someone help me understand what might be going wrong here?

I'm writing a class template that looks something like this;

/* myclass.h */
#include<vector>
using namespace std

template <class ND>
class MyClass {
public:
vector<ND*> myvector;
vector<ND*>::iterator myit;
};
The problem is in the declaration of the iterator. When I compile, it
gives the error
syntax error before `;' token
for that line, then I get a long list of other meaningless errors.
There is no problem declaring the vector itself, and if I replace ND* in
the problem line with e.g. double*, then it has no problem with that
line, leading me to believe the syntax is actually OK. I am using g++
to compile this in Linux.

Any ideas?

Thanks!
Oct 27 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
TIT
Jim Luedtke sade:
Can someone help me understand what might be going wrong here?

I'm writing a class template that looks something like this;

/* myclass.h */
#include<vector>
using namespace std

template <class ND>
class MyClass {
public:
vector<ND*> myvector;
vector<ND*>::iterator myit;
typename vector<ND*>::iterator myit;
};


TIT
Oct 27 '05 #2

P: n/a
Jim Luedtke wrote:
Can someone help me understand what might be going wrong here?

I'm writing a class template that looks something like this;

/* myclass.h */
#include<vector>
using namespace std

template <class ND>
class MyClass {
public:
vector<ND*> myvector;
vector<ND*>::iterator myit;
typename vector<ND*>::iterator myit;
};
[...]


And read the FAQ, often.

V
Oct 27 '05 #3

P: n/a
Thanks and I will.

Jim

Victor Bazarov wrote:
Jim Luedtke wrote:
Can someone help me understand what might be going wrong here?

I'm writing a class template that looks something like this;

/* myclass.h */
#include<vector>
using namespace std

template <class ND>
class MyClass {
public:
vector<ND*> myvector;
vector<ND*>::iterator myit;

typename vector<ND*>::iterator myit;
};

[...]

And read the FAQ, often.

V

Oct 27 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.