I'm in the process of doing some game work with vectors and have come upon an unexpected problem. When I try to add new items to the vectors, my program complains and fails to run. The MSVC++ 2005 EE debugger points me towards an error caused by the vector size() function.
Specifically, it tells me that the return statement caused the error (kinda obvious since that is the only statement in there). I am not calling the size() function and though I'm relatively new to using vectors I'm thinking (correct me if I'm wrong) that when I call push_back() to add an item to the vector it probably internally calls the size() function.Code:size_type size() const
{ // return length of sequence
return (_Myfirst == 0 ? 0 : _Mylast - _Myfirst);
}
Code pretaining to my use of vectors (I'm using the std namespace which is why I'm not using std::, I didn't think that had a great effect on anything):
I initialize it here
Then here is where I try to add an item to the vector.Code:vector<Mesh *> MeshList;
TempMesh is a filled in Mesh structure initialized thus:Code:MeshList.push_back(TempMesh);
And filled in accordingly afterwards.Code:Mesh *TempMesh = new Mesh();
Specifically, the debugger tells me:
Though that probably isn't much help to anything.Quote:
Unhandled exception at 0x00412be6 in Direct3D Test.exe: 0xC0000005: Access violation reading location 0x00000008.
Do I need to initialize the vector different? Is it mad that I'm not putting anything at all in it?
