problem declaring vector iterator in class template

J

Jim Luedtke

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!
 
T

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 said:

TIT
 
V

Victor Bazarov

Jim said:
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 said:

And read the FAQ, often.

V
 
J

Jim Luedtke

Thanks and I will.

Jim

Victor said:
Jim said:
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 said:


And read the FAQ, often.

V
 

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,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top