Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Error Using std::vector [modified]

Error Using std::vector [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++graphicstutorial
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Larry Mills Sr
    wrote on last edited by
    #1

    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

    C 1 Reply Last reply
    0
    • L Larry Mills Sr

      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

      C Offline
      C Offline
      Cedric Moonen
      wrote on last edited by
      #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]

      L 1 Reply Last reply
      0
      • C Cedric Moonen

        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]

        L Offline
        L Offline
        Larry Mills Sr
        wrote on last edited by
        #3

        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

        B 1 Reply Last reply
        0
        • L Larry Mills Sr

          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

          B Offline
          B Offline
          BhawnaA
          wrote on last edited by
          #4

          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

          C 1 Reply Last reply
          0
          • B BhawnaA

            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

            C Offline
            C Offline
            Cedric Moonen
            wrote on last edited by
            #5

            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]

            B 1 Reply Last reply
            0
            • C Cedric Moonen

              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]

              B Offline
              B Offline
              BhawnaA
              wrote on last edited by
              #6

              Use this code using std::vector; Thanks Bhawna

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups