Got errors when using iterator. Please help me!

This is a discussion on Got errors when using iterator. Please help me! within the C++ Programming forums, part of the General Programming Boards category; I don't understand why these error occur. Anything wrong with syntax? Please help me! Thank you very much! btw: I ...

  1. #1
    C/C++Newbie Antigloss's Avatar
    Join Date
    May 2005
    Posts
    212

    Got errors when using iterator. Please help me!

    I don't understand why these error occur. Anything wrong with syntax? Please help me! Thank you very much!

    btw: I use MS VC++ to compile these code.

    Code:
    #include <vector>
    
    using std::vector;
    using std::iterator;
    
    int main()
    {
    	vector<int> a(10, -1);
    	vector<int>::iterator b = a.begin();
    	return 0;
    }
    --------------------Configuration: a - Win32 Debug--------------------
    Compiling...
    a.cpp
    E:\Study\Algorithm\try\a.cpp(10) : error C2653: 'vector<int,class std::allocator<int> >' : is not a class or namespace name
    E:\Study\Algorithm\try\a.cpp(10) : error C2955: 'iterator' : use of class template requires template argument list
    d:\program files\microsoft visual studio\vc98\include\utility(71) : see declaration of 'iterator'
    E:\Study\Algorithm\try\a.cpp(10) : error C2514: 'std::iterator' : class has no constructors
    d:\program files\microsoft visual studio\vc98\include\utility(71) : see declaration of 'iterator'
    E:\Study\Algorithm\try\a.cpp(10) : error C2262: 'b' : cannot be destroyed
    Error executing cl.exe.

    a.obj - 4 error(s), 0 warning(s)

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    181
    it seems to compile fine for me. what compiler are u using

    s.s.harish

  3. #3
    C/C++Newbie Antigloss's Avatar
    Join Date
    May 2005
    Posts
    212
    Microsoft Visual C++ 6

    I've found 2 solution. Either to use "using namespace std", or to add "std::" before "vector<int>::iterator b = a.begin();"

    Maybe it's because there are some problems with msvc++6

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. global namespace errors
    By stubaan in forum C++ Programming
    Replies: 9
    Last Post: 04-02-2008, 03:11 PM
  2. Ten Errors
    By AverageSoftware in forum Contests Board
    Replies: 0
    Last Post: 07-20-2007, 10:50 AM
  3. Stupid compiler errors
    By ChrisEacrett in forum C++ Programming
    Replies: 9
    Last Post: 11-30-2003, 04:44 PM
  4. Help me with these errors... :-(
    By major_small in forum C++ Programming
    Replies: 6
    Last Post: 09-07-2003, 08:18 PM
  5. errors in class(urgent)
    By ayesha in forum C++ Programming
    Replies: 2
    Last Post: 11-10-2001, 05:51 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21