im coming from PHP where i would do
$um['Im a string'][1] = 3;
for a 2d associative array where the first key is a string, the second an integer and the value is an integer as well. I try to do the same in c++. here is my attempt:
// experiment.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <unordered_map>
#include <vector>
#include <string>
using std::vector;
using std::string;
using std::unordered_map;
int _tmain(int argc, _TCHAR* argv[])
{
unordered_map <string,vector<int,int>> um;
um["Im a string"][1] = 3;
printf("Out: %d", um["Im a string"][1]);
return 0;
}
obviously its not the right syntax;
vector<int,int>isn’t correct (vectorisn’t an associative container), you probably want a nestedunordered_map<int>. So: