I tried to write my code, and it looks like something like this (i cut some of them to make it readable).

class TimeSeriesDatum
	//TimeSeriesDatum( double = 0, int = 0, string = "");	
	TimeSeriesDatum( double, int, string );
	// getter, setter...
	double value;

// in the main
vector<TimeSeriesDatum> myvector;
[B]vector<TimeSeriesDatum>::iterator it;[/B] // 4 errors in this line

And i've got 4 errors for the bold lines in my code, i wonder why. If you have ever had the same problem, can you let me know the solutions?

The errors are:
1) error C2653: 'vector<class TimeSeriesDatum,class std::allocator<class TimeSeriesDatum> >' : is not a class or namespace name
2) error C2065: 'iterator' : undeclared identifier
3) error C2146: syntax error : missing ';' before identifier 'it'
4) error C2065: 'it' : undeclared identifier

Thank you for your attention. I'll wait for your reply.

10 Years
Discussion Span
Last Post by Ancient Dragon

yes, finally i found it.
I had this before:

// coding A
#include <vector>
using std::vector;

and i changed it to:

// coding B
#include <vector>
using namespace std;

and it produced no error. but i wonder why when i add another using statement, i.e. "using std::vector::iterator;" in coding B, also produced errors?



probably something else wrong with your program because this one compiles ok. using std::vector::iterator -- no such thing.

#include <string>
#include <vector>
using std::vector;

using std::string;

int main()
    vector<string> v;
    vector<string>::iterator it;

thx for your answer. yes, it's maybe because i tried to use visual C++ 6.0 at windows vista. hope that it won't be much different with the one at windows xp.


ditch that compiler because it doesn't implement c++ very well. Better to get newest free Visual C++ 2008 Express -- you can download it free from Microsoft.

>>because i tried to use visual C++ 6.0 at windows vista
That's not the problem -- the problem is the compiler itself.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.