473,799 Members | 3,072 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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*>::it erator 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 1767
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*>::it erator myit;
typename vector<ND*>::it erator 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*>::it erator myit;
typename vector<ND*>::it erator 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*>::it erator myit;

typename vector<ND*>::it erator 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
2150
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 that the algorithm will behave differently for the two different types. I've considered calling the algorithm foo_A and foo_B, but I don't like that approach because it will blow out in naming complexity down the track.
9
8897
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; Any ideas why is tihs happening? The code is as follows: template <class T> struct StdVectorStorage { std::vector<T>* _storage;
24
2964
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 vector<Corres>{ public: void addCorres(Corres& c); //it do little more than push_back function. }
15
2185
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 a class and users of the class get to iterate it via a const_iterator. eg.
8
1885
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): --------------------------------------------------------------------- template<class T> class myvector { // Just a simplification of std::vector class iterator { T a; iterator &operator++(); };
7
2316
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; iter = a;
7
2029
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 default value std::vector<T>). To handle the different ways that the values are randomized, I created a traits class. The problem that I have, is that the function randomize() within the traits class takes different parameters depending on the type...
4
2010
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 strange. The implementation looks like this (there is a lot of code, but I have only included it all for consistency. The problem is quite small and local): template<typename T> class Row<T> : public std::vector<T> {}; template<typename...
6
1733
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 code public interface IMagasin { public double getLatitude(); public double getLongitude(); public String getCode(); public String getVille(); public void setLatitude(double l); public void setLongitude(double lon);
0
10484
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10228
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10027
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9072
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6805
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5463
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4141
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3759
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.