lundi 7 novembre 2016

Creating a link between two vectors in c++

This is a conceptual question, so I am not providing the "working code" for this reason.

Imagine one has two std::vector of different types and different number of entities, just for example:

vector <int> A;
vector <string> B;

One has a set of rules following which one can associate any members of A with some(or none) of the members of B.

Is there a way to "store" this connection?

I was thinking that one of the ways to do so is having a vector <map <int, vector <string> > > or vector <map <int, vector <string*> > >, but this solutions seems to me unreliable (if A contains two same numbers for example) and I assume there are much more elegant solutions somewhere there.

Aucun commentaire:

Enregistrer un commentaire