Camron
Camron

Reputation: 41

Can you have an array of maps in C++?

If so how? Because currently trying to handle input for multiple players using a map of actions.

Upvotes: 4

Views: 12325

Answers (1)

user236520
user236520

Reputation:

std::vector<std::map<a,b> >

or if you want to handle the construction/destruction yourself

std::vector<std::map<a,b>* >

where a and b are the keys/values in your map

For example:

#include <vector>
#include <map>

int main(int argc, char* argv[])
{
   std::vector<std::map<int,int>> vecOfMaps;
   std::vector<std::map<int,int>*> vecOfMaps2;
   return 0;
}

Upvotes: 3

Related Questions