#include <iostream>
#include<map>
#include<string>
#include<vector>
template<class Key, class T, class Compare = std::less<Key> >
class map_storage{
public:
//------------------------------------v--------------->pointer
void add(std::map<Key, T, Compare>* temp_map){
data_.push_back(temp_map);
}
void doSomething(){
std::cout << data_.size() << std::endl;
std::cout<< data_.at(0)->size(); //prints 2
}
private:
//---------------------------------------v------------->pointer
std::vector<std::map<Key, T, Compare>* > data_;
};
int main()
{
std::map<std::string, int> map1;
map_storage<std::string, int> ms;
//-----------------------^----------->added comma here which was missing in the original code
ms.add(&map1);
map1["asd"] = 1;
map1["dsa"] = 2;
ms.doSomething();
}