Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is this a valid datastructure Map<string, string, string> in C++?

Tags:

c++

I have to store 3 strings per variable, but don't know which is the best data structure to use for that in C++.
I can think of only Struct, but not sure if it is the best way to do it.

Something like string var[100][3], first dimension(100) should be dynamically add and remove.

I tried all sorts of things with map, multimap.

Any help is appreciated. Thank you

like image 456
rda3mon Avatar asked Dec 09 '22 11:12

rda3mon


1 Answers

If you have always exactly 3 strings together in a triplet and want to have multiple triplets, then define struct with three strings and put it to std::vector.

struct Triplet {
  std::string a,b,c;
};

std::vector<Triplet> data;
like image 128
Al Kepp Avatar answered Mar 06 '23 17:03

Al Kepp