Ask coding questions

← Back to all posts
[SOLVED] Referencing member 0 of uninitialized vector (array)
h
SPQR (533)

I've been getting the exception "std::out_of_range" and the program aborts ever since I tried to implement projectiles. The error persists even after undoing my changes. I've commented out all lines of code referencing the new addition, but I still get the exception regardless. I've narrowed it down to referencing the first member of an uninitialized vector (accessing member 0 of a vector whose size is 0.) I need someone to help me to find the cause of the exception. The error would be the result of something in either entity.cpp, entity.hpp, framework.hpp, or main.cpp. Everything else has been unchanged for some time.

EDIT: After 4 days of trying to figure this out, I fixed the problem within 3 mins of posting this on my own. I forgot to initialize a vector in one of my default constructors, which is a problem when I use it in a derived class. Basically, classes are annoying.

Commentshotnewtop
a5rocks (793)

Nice job! Rubber ducky debugging ftw!