473,385 Members | 1,312 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.

problem declaring vector iterator in class template

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
3 1749
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Sherrie Laraurens | last post by:
Hi all, I'm trying to write a generic algorithm routine that will take begin and end iterators of a container, iterate through the range and perform a "calculation" of sorts. The trouble is...
9
by: aaragon | last post by:
I am trying to create a vector of type T and everything goes fine until I try to iterate over it. For some reason, the compiler gives me an error when I declare std::vector<T>::iterator iter;...
24
by: toton | last post by:
Hi, I want to have a vector like class with some additional functionality (cosmetic one). So can I inherit a vector class to add the addition function like, CorresVector : public...
15
by: fungus | last post by:
I'm moving some code from VC++ 6 to VC++ 2005 and I've run into a nasty problem because iterators are no longer pointers. In the program I'm moving, there's a std::vector of items hidden inside...
8
by: Fab | last post by:
All, I need your help understanding why the following code does *NOT* compile with G++ (tested with gcc 3.x and 4.1.x): ---------------------------------------------------------------------...
7
by: desktop | last post by:
I am not sure I quite understand the use of iterators. I have this int array: int a = {1,2,3,4,5} I would now like to make an iterator to the first and last element: std::iterator<intiter;...
7
by: aaragon | last post by:
Hi everyone, The idea is quite simple: generate a container with random values in it. For that, I decided to create a class that I called RandomContainer that inherits from a container (with...
4
by: mkborregaard | last post by:
Hi, I have the weirdest problem, and I can not see what is going wrong. I have made a 2d container class, and am implementing an iterator for that class. However, the ++ operator is behaving very...
6
by: manjava | last post by:
Hello , please can any one help me for my this i don't know why didn't gave me my return true he juste return this :les magasins situés dans la ville projetd314.ListeMagasin@a401c2 why see my...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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: 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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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.