Removing from the front of a Vector

This is a discussion on Removing from the front of a Vector within the C++ Programming forums, part of the General Programming Boards category; Hello, I'm new to C++ and I was wondering how you would go about removing from the front of a ...

  1. #1
    Registered User
    Join Date
    Sep 2003
    Posts
    69

    Question Removing from the front of a Vector

    Hello,

    I'm new to C++ and I was wondering how you would go about removing from the front of a Vector. I know you can use pop_back() to remove from the back, but I can't seem to find any way of removing from the front. If someone could show me the code on how to do this, that would be great. Thanks.

  2. #2
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,672
    Code:
    vector<int> IntVect;
    ...
    IntVect.erase(IntVect.begin());
    If you're going to be erasing many elements from the front of a vector you might want to consider a deque container instead.
    Last edited by hk_mp5kpdw; 09-11-2004 at 10:51 AM.
    I used to be an adventurer like you... then I took an arrow to the knee.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. can some one please tell me the cause of the error ?
    By broli86 in forum C Programming
    Replies: 8
    Last Post: 06-26-2008, 08:36 PM
  2. syntax help?
    By scoobygoo in forum C++ Programming
    Replies: 1
    Last Post: 08-07-2007, 10:38 AM
  3. Vector class
    By Desolation in forum C++ Programming
    Replies: 2
    Last Post: 05-12-2007, 05:44 PM
  4. Need some help/advise for Public/Private classes
    By nirali35 in forum C++ Programming
    Replies: 8
    Last Post: 09-23-2006, 12:34 PM
  5. Certain functions
    By Lurker in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2003, 12:26 AM

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