How best way to store information like this?

I have class Guy. And I want to store information about him: the number of times he has been to each country, the number of dates he's had with a girl from that country, the different names of all those girls of that country he's dated, the names of every girlfriend he's had from that country, etc... (and all this for every country he's been to or 'experienced').

So I was thinking something like

1
2
3
4
5
6
7
class Guy 
{ 
    public: 
        vector<pair<string, int[2]> > countryStats;
        vector<pair<string, vector<string> > > countryDateNames;
        vector<pair<string, vector<string> > > countryGirlfriendNames;
}


The first string in each pair is the country name. Then int[2] for the two numerical data mentioned above, and then vector<string> for the names of all the dates and girlfriends (of that country). But this looks awfully messy. Is there a cleaner way to store all this info in just one go?
Last edited on
I would make another structure that stores all the information like so:
1
2
3
4
5
6
struct countryData {
  int visits;
  int dates;
  std::vector<string> date_names;
  std::vector<string> gf_names;
};

Then inside your actual class just have something like:
1
2
3
4
class Guy {
   // ...
   std::map<std::string, countryData> stats; // map from country name to data
};
Thanks, this worked beautifully. I'm glad I avoided the nightmare of my first idea.
Topic archived. No new replies allowed.