| | |
Custom class vector iterator error
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Oct 2008
Posts: 3
Reputation:
Solved Threads: 0
I tried to write my code, and it looks like something like this (i cut some of them to make it readable).
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.
class TimeSeriesDatum
{
public:
TimeSeriesDatum();
//TimeSeriesDatum( double = 0, int = 0, string = "");
TimeSeriesDatum( double, int, string );
// getter, setter...
private:
double value;
};
// in the main
vector<TimeSeriesDatum> myvector;
vector<TimeSeriesDatum>::iterator it; // 4 errors in this lineAnd 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.
Last edited by dulusementara; Oct 3rd, 2008 at 6:36 am.
•
•
Join Date: Oct 2008
Posts: 3
Reputation:
Solved Threads: 0
yes, finally i found it.
I had this before:
and i changed it to:
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?
Thx.
I had this before:
C++ Syntax (Toggle Plain Text)
// coding A #include <vector> using std::vector;
and i changed it to:
C++ Syntax (Toggle Plain Text)
// 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?
Thx.
probably something else wrong with your program because this one compiles ok.
using std::vector::iterator -- no such thing. C++ Syntax (Toggle Plain Text)
#include <string> #include <vector> using std::vector; using std::string; int main() { vector<string> v; vector<string>::iterator it; }
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
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.
>>because i tried to use visual C++ 6.0 at windows vista
That's not the problem -- the problem is the compiler itself.
Last edited by Ancient Dragon; Oct 3rd, 2008 at 8:14 am.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
![]() |
Similar Threads
- Custom Class - File I/O (C++)
Other Threads in the C++ Forum
- Previous Thread: Gaussian Noise function for images
- Next Thread: Having problems with istream operator
| Thread Tools | Search this Thread |
Tag cloud for C++
api application array arrays based beginner binary bmp c++ c/c++ calculator char char* class classes code compile compiler console conversion convert count data delete deploy dll download dynamiccharacterarray email encryption error file format forms fstream function functions game givemetehcodez graph homeworkhelp iamthwee ifstream input int java lib library lines list loop looping loops map math matrix memory newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg search simple sorting spoonfeeding string strings struct temperature template templates text text-file tree url variable vector video visual visualstudio void win32 windows winsock wordfrequency wxwidgets






