PDA

View Full Version : std::vector



ToddAtWSU
28th September 2007, 14:40
I have a vector not (QVector) of pointers to a struct. I am reusing the same window in my project and just clearing the vector and re-populating it when the data changes. The program keeps crashing when I initially try to run the program though, and it's because I am trying to clear a vector that has had nothing done it to. I call the same function when I load new data, and this function wants to clear the vector. I figured there was no harm clearing a vector I hadn't used but apparently this is not so.

So is there a way to have a vector declared in my .h file, and skip clearing it the first time through, but then clear it after that? Even if I try to check it's size to see if it's greater than 0, it crashes. Thanks for your help.

ToddAtWSU
28th September 2007, 15:14
Boy am I feeling stupid. If you never initialize the class containing the vectors, it's a little hard to work with the class's vectors. :eek: I am surprised it got that far since the class object was NULL. Oh well, thanks for your help anyways.