Re: removing the 5th STL object

Discussion in 'C++' started by John Harrison, Jun 28, 2003.

  1. "Søren Grønbech" <> wrote in message
    news:3efdd7ff$0$24705$...
    > std::vector<long>::iterator i=online_userid.begin();
    > i += 5;
    > online_userid.erase(i);
    >
    > It the above ok?
    > removing object #5 (really the sixth)..
    >
    > Thanx,
    > Søren
    >


    It's OK, a shorter alternative is

    online_userid.erase(online_userid.begin() + 5);

    john
     
    John Harrison, Jun 28, 2003
    #1
    1. Advertising

  2. thank you very much !

    "John Harrison" <> wrote in message
    news:bdkm1s$tbak3$...
    >
    > "Søren Grønbech" <> wrote in message
    > news:3efdd7ff$0$24705$...
    > > std::vector<long>::iterator i=online_userid.begin();
    > > i += 5;
    > > online_userid.erase(i);
    > >
    > > It the above ok?
    > > removing object #5 (really the sixth)..
    > >
    > > Thanx,
    > > Søren
    > >

    >
    > It's OK, a shorter alternative is
    >
    > online_userid.erase(online_userid.begin() + 5);
    >
    > john
    >
    >
     
    Søren Grønbech, Jun 28, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    5
    Views:
    625
    Roedy Green
    Apr 13, 2006
  2. Replies:
    0
    Views:
    548
  3. Stephen Howe

    Re: removing the 5th STL object

    Stephen Howe, Jun 28, 2003, in forum: C++
    Replies:
    0
    Views:
    727
    Stephen Howe
    Jun 28, 2003
  4. Kishor
    Replies:
    13
    Views:
    1,542
    Sidney Cadot
    Feb 3, 2004
  5. Richard Jones
    Replies:
    0
    Views:
    235
    Richard Jones
    Aug 4, 2007
Loading...

Share This Page