Is this a valid good practice? (assume that ARENAPLAYER is a struct)
ARENAPLAYER* CArena::GetPlayer( u_long idPlayer )
{
map<u_long, ARENAPLAYER>::iterator it = m_mArenaMap.find( idPlayer );
if( it != m_mArenaMap.end() )
return &it->second;
return NULL;
}
If it is, will the pointer point directly to the object inside the map? Any changes made by the pointer will change the object in the map?
You can get pointers to the objects inside the
std::map<u_long, AREANPLAYER>like this. The objects inside a map stay put as long as the map lives and the object isn’t erased from the map.