title: is map<string, string[]> possible in C++?
body: <p>I am trying to learn C++ by converting some programs I wrote in java. One is an encryption program that takes text input and makes it look like DNA ( AGCTGTGCT... ). I can encrypt 64 characters using 256 codons of 4 bases each. ( "A" = "TGGC", "B" = "ATGC"...) In java, I make a <code>hashmap&lt;String, String[]&gt;</code> where the key is the character to be encrypted and the value is an array of 4 strings, where each string is a codon that is chosen at random to replace the encrypted character. </p>
  
  <p>In C++ I am trying to use a map to do the same thing, but it gives an error I just don't understand. Here is the code where I try to make the codon table:</p>
  
  <pre><code>// iterate through the characters and select 4 codons from the list
  for(int i = 0; i &lt; 64; i++){
      codonTable[charList[i]][0] = originalCodonList[4 * i];
      codonTable[charList[i]][1] = originalCodonList[4 * i + 1];
      codonTable[charList[i]][2] = originalCodonList[4 * i + 2];
      codonTable[charList[i]][3] = originalCodonList[4 * i + 3];
  
      }
  }
  </code></pre>
  
  <p><code>charList</code> is the array that holds the 64 encodable characters ( they are really strings ) and <code>originalCodonList</code> is a string array that contains the 256 codons. I've tried several ways to assign 4 codons to the string array in the map, but nothing really seems to work. This generates the least error spam. Here is the output when I compile it:</p>
  
  <blockquote>
    <p>In file included from /usr/include/c++/4.6/map:61:0,
                    from Genencrypt.cpp:4:
    /usr/include/c++/4.6/bits/stl_map.h: In member function ‘std::map&lt;_Key, _Tp, _Compare, >_Alloc>::mapped_type&amp; std::map&lt;_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&amp;) >[with _Key = std::basic_string, _Tp = std::basic_string [4], _Compare = >std::less >, _Alloc = std::allocatorstd::basic_string, std::basic_string [4]> >, std::map&lt;_Key, _Tp, _Compare, >_Alloc>::mapped_type = std::basic_string [4], std::map&lt;_Key, _Tp, _Compare, >_Alloc>::key_type = std::basic_string]’:
    Genencrypt.cpp:63:25:   instantiated from here
    /usr/include/c++/4.6/bits/stl_map.h:453:11: error: conversion from ‘int’ to non-scalar type >‘std::map, std::basic_string [4]>::mapped_type {aka >std::basic_string [4]}’ requested</p>
  </blockquote>
  
  <p>Of course google tells me it's too long when I copy it into google. I'm not an expert in java, and I am much much better at java than at c++.</p>
  
  <p>TL;DR: I want to make a <code>map&lt;string, string[]&gt;</code> in c++, is it possible and how to do it?</p>
  
  <p>EDIT: Here is how I fixed it, I changed codonList from <code>map&lt;string. string[]&gt;</code> to <code>map&lt;string, vector&lt;string&gt; &gt;</code> and used this code to add the codons</p>
  
  <pre><code>    for(int i = 0; i &lt; 64; i++){
      codonTable[charList[i]].push_back(originalCodonList[4 * i]);
      codonTable[charList[i]].push_back(originalCodonList[4 * i + 1]);
      codonTable[charList[i]].push_back(originalCodonList[4 * i + 2]);
      codonTable[charList[i]].push_back(originalCodonList[4 * i + 3]);
      std::cout &lt;&lt; "Working?" &lt;&lt; std::endl;
      }
  </code></pre>