Original Post
Hi there,
My vector elements get corrupted after I call push_back() to another vector. The following code shows the problem:
Any ideas what might be causing this? and more importantly how to solve this?
[Edit] I use Visual Studio 2008, I've determined the corruption trough the debugger, also the corruption causes problems in other areas of my code.
My vector elements get corrupted after I call push_back() to another vector. The following code shows the problem:
{ vector<Waypoint*> vecWaypoints; for(UINT j = 0; j < vecPaths.at(i).vecWaypoints.size(); j++) { Waypoint waypoint; waypoint.vPos = vecPaths.at(i).vecWaypoints.at(j).vPos; waypoint.vecG = vecPaths.at(i).vecWaypoints.at(j).vecG; pPath->vecWaypoints.push_back(waypoint); //after this call vecWaypoints' elements get corrupted Waypoint *pWaypoint = &pPath->vecWaypoints.back(); vecWaypoints.push_back( pWaypoint ); //first element is fine until the call to pPath->vecWaypoints.push_back(waypoint) } pPath->vecWaypointGroups.push_back(vecWaypoints);}Any ideas what might be causing this? and more importantly how to solve this?
[Edit] I use Visual Studio 2008, I've determined the corruption trough the debugger, also the corruption causes problems in other areas of my code.