Ho provato ma non riesco a replicare il tuo errore. Questo è il codice che ho utilizzato:
codice:
#include <iostream>
#include <vector>
#include <string>
using namespace std;
const unsigned int num_letters = ('z' - 'a') + 1;
typedef std::vector<std::string> dictionary [num_letters];
void print_dictionary(dictionary d) {
for(unsigned int i=0; i<num_letters; ++i) {
for(unsigned int j=0; j<d[i].size(); ++j) {
cout << d[i][j] << endl;
}
}
}
int main()
{
dictionary D;
string word = "apple";
D[word[0]-'a'].push_back(word);
string another_word = "tree";
D[another_word[0]-'a'].push_back(another_word);
print_dictionary(D);
return 0;
}