У меня есть следующий код:
class Thing
{
private:
Item item;
};
class Mgr{
public:
std::map<int, Item*> sps;
};
void Thing::addItemToMap(std::map<int, Item*>& sps, int i){
sps.insert(std::make_pair(i, &(this->item)));
}
void Mgr::accessItem( int i){
auto it = sps.find(i);
if(it!=sps.end(){
// it->second is the instance of Item I inserted in the map before?
}
}
У Mgr будет возможность получить тот же экземпляр элемента Thing->, который вставила Thing, вызывая "addItemToMap" с ключом "i = 3")метод "accessItem (3)"?