Corrupted STL vector?

This is a discussion on Corrupted STL vector? within the C++ Programming forums, part of the General Programming Boards category; Ok, so this is my problem: Yesterday, my code was working perfectly, if slowly. Today, my code isn't. It crashes ...

  1. #1
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879

    Corrupted STL vector?

    Ok, so this is my problem: Yesterday, my code was working perfectly, if slowly. Today, my code isn't. It crashes for no reason that I can see. This is the function:

    PHP Code:
    void Alien::handleShots(GFXgfx)
    {
         for(
    int i 0shots.size(); ++i)
         {
              if(!
    shots[i]->move())     //Crashes here
              
    {
                   
    delete shots[i];
                   
    shots.erase(&shots[i]);
              }
              else
                   
    shots[i]->draw(gfx);
         }

    I found out that it crashed before it got into the move() function, and then I found out that whenever it crashed, it was because the vector was empty but size() returned a 10-digit number! Is my vector class corrupted or something?

    P.S. I haven't changed my code since yesterday.
    Last edited by Hunter2; 08-21-2002 at 12:17 PM.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  2. #2
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    NVM, the problem had nothing to do with that, even though it crashed on that particular line (dunno why, the problem was totally unrelated).
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

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, 09:36 PM
  2. syntax help?
    By scoobygoo in forum C++ Programming
    Replies: 1
    Last Post: 08-07-2007, 11:38 AM
  3. Vector class
    By Desolation in forum C++ Programming
    Replies: 2
    Last Post: 05-12-2007, 06:44 PM
  4. Need some help/advise for Public/Private classes
    By nirali35 in forum C++ Programming
    Replies: 8
    Last Post: 09-23-2006, 01:34 PM
  5. Certain functions
    By Lurker in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2003, 01:26 AM

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