mercredi 29 novembre 2017

C++ insert a value in a set of values from a class in a Map

I have a map in my class Cjt_Trets that contains a string called rasgo and a class called Trets. In Trets I have a set<int> id; that will contain the id's of the people containing that rasgo. My problem comes when I try to insert the id that the function receives, into that set. How am I supposed to do it?

Here I leave part of the code that can help you understand better my situation:

Private of the class Cjt_Trets

private:
  map<string, Trets> mtrets;  
};

Private of Trets

private:
  set<int> id;
  string gen;  
};

Actual part of the code I don't know how to do:

void Cjt_Trets::afegir_tret(int id, string rasgo){    
  mtrets.insert( make_pair<string, Trets> (rasgo, Trets.id.insert(id)) );
}

Thanks a lot

Aucun commentaire:

Enregistrer un commentaire