I have a class named Group
:
class Group
{
int id;
string addr;
set<int> members;
...
};
I have pointers to multiple groups stored in these containers:
vector<Group*> grpVec
map<int, Group*> grpIdMap
map<string, Group*> grpAdMap
I am storing the pointers like this:
//create and populate group object pointer Group *grp
grpVec.push_back(grp)
grpIdMap.insert(std::pair<int,Group*>(grp->id, grp))
grpAdMap.insert(std::pair<string,Group*>(grp->addr, grp))
Now, I want to update a group object. If I update only the pointer in the grpIdMap container, will the same object pointer in all other containers get updated?
//Will this update the same pointer object in grpVec and grpAdMap?
grpIdMap.find(1)->second->members.insert(99)
Is there any issue in this approach?