 <p>You need only to vector of vector of string:</p> <pre><code>vector&lt;vector&lt;string&gt; &gt; table((int)('z' - 'a')); string str; while (cin &gt;&gt; str) { table[tolower(str[0]) - 'a'].push_back(str); } </code></pre> <p>To clarify:</p> <ul> <li><code>table</code> is of length 26 (which is the result of <code>'z' - 'a'</code>), since we have 26 alpha chars.</li> <li>Each of the 26 elements is a vector of strings.</li> <li>When we put the read string, we put it in an index relative to its first char.</li> </ul> <p>For example: "all" => `tolower(str[0] - 'a') = 0</p> <p>About your code:</p> <pre><code>class index_table { public: index_table() { table.resize(128);} void insert(string &amp; ); // Don't need second param private: class entry { //Subclass string word; // vector&lt;int&gt; is not needed } vector&lt; vector &lt;entry &gt; &gt; table; // Don't need list type }; void index_table::insert(string &amp; s) { if (s.size() == 0) return; else table[(int)(s[0])].push_back(s); // (int)(s[0]) bring ASCII code } </code></pre>