That will work only if the searched item is actually present in the map
. Otherwise using it will cause undefined behavior. You should use something like the following
std::map<unsigned int, QGF6::GameObject*>::iterator itr = lMap.find(p.id);
if(itr!= lMap.end()){ //found
//use it
}
or,
QGF6::GameObject* obj = lMap[p.id];
if( obj!=nulptr){
//use it
}