Error Using std::vector [modified]
-
I'm trying to load data into a vector and simply can't fiquire out how to do it. Here's the class that holds (should) hold the data: class CMyTrailer { public: // Varables CString m_csData; CMyTrailer(); ~CMyTrailer(); }; #include using std::vector; using std::copy; using std::iterator; using std::string; Here's my error from the compiler: error C2653: 'vector >' : is not a class or namespace name error C2653: 'vector >' : is not a class or namespace name error C2955: 'iterator' : use of class template requires template argument list Here's my vector declaration: vector TRL_MFG; vector::iterator TRL_ITItem; Can any one help, Please! -- modified at 14:17 Monday 19th November, 2007 A C++ programming language novice, but striving to learn
-
I'm trying to load data into a vector and simply can't fiquire out how to do it. Here's the class that holds (should) hold the data: class CMyTrailer { public: // Varables CString m_csData; CMyTrailer(); ~CMyTrailer(); }; #include using std::vector; using std::copy; using std::iterator; using std::string; Here's my error from the compiler: error C2653: 'vector >' : is not a class or namespace name error C2653: 'vector >' : is not a class or namespace name error C2955: 'iterator' : use of class template requires template argument list Here's my vector declaration: vector TRL_MFG; vector::iterator TRL_ITItem; Can any one help, Please! -- modified at 14:17 Monday 19th November, 2007 A C++ programming language novice, but striving to learn
Did you include the file where CMyTrailer is declared in the file where you are declaring your vector ?
Cédric Moonen Software developer
Charting control [v1.2] -
Did you include the file where CMyTrailer is declared in the file where you are declaring your vector ?
Cédric Moonen Software developer
Charting control [v1.2]I think the answer is yes: here's the header: // Trailer.h #if !defined(AFX_TRAILER_H) #define AFX_TRAILER_H #include "MyTrailer.h" #include using std::vector; using std::copy; using std::iterator; using std::string; class CTrailer { public: CTrailer(int nIsPage=0); ~CTrailer(); // Varables: // Vectors: // Setup vectors: vector TRL_ITEM; vector TRL_MFG; vector TRL_ID; vector::iterator TRL_ITItem; vector::iterator TRL_ITMFG; vector::iterator TRL_ITID; vector m_vITEM; // Item vector m_MFG; // MFG vector vector m_IDNUM; // Part#/ID# // Iterators: vector::iterator m_ITItem; vector::iterator m_ITMFG; vector::iterator m_ITID; //Functions: }; #endif -- modified at 21:55 Monday 19th November, 2007 A C++ programming language novice, but striving to learn
-
I think the answer is yes: here's the header: // Trailer.h #if !defined(AFX_TRAILER_H) #define AFX_TRAILER_H #include "MyTrailer.h" #include using std::vector; using std::copy; using std::iterator; using std::string; class CTrailer { public: CTrailer(int nIsPage=0); ~CTrailer(); // Varables: // Vectors: // Setup vectors: vector TRL_ITEM; vector TRL_MFG; vector TRL_ID; vector::iterator TRL_ITItem; vector::iterator TRL_ITMFG; vector::iterator TRL_ITID; vector m_vITEM; // Item vector m_MFG; // MFG vector vector m_IDNUM; // Part#/ID# // Iterators: vector::iterator m_ITItem; vector::iterator m_ITMFG; vector::iterator m_ITID; //Functions: }; #endif -- modified at 21:55 Monday 19th November, 2007 A C++ programming language novice, but striving to learn
-
Hi Put this code using namespace std; instead of using std::vector; using std::copy; using std::iterator; using std::string; and I hope it works fine. Warm Regards Bhawna
I never use
using namespace
in a header file. This will 'propagate' the namespace across all files that include this specific header file, leading to potential conflicts. In header files, I just put the namespace with the class declaration:std::vector<MyClass> ....
Cédric Moonen Software developer
Charting control [v1.2] -
I never use
using namespace
in a header file. This will 'propagate' the namespace across all files that include this specific header file, leading to potential conflicts. In header files, I just put the namespace with the class declaration:std::vector<MyClass> ....
Cédric Moonen Software developer
Charting control [v1.2]