array of structures
i have a linked list containing strings (names), but what i need is an array of linked lists. i know that the array would have max of 20 elements (0-1)
gives me one list of 20 elements, but i need 20 lists of x elements.
vector <string> nameList(20);
how could i go about this??
You want an array of vectors containing strings.
That should create a vector (array) of 20 empty lists that can hold strings. To add a string to a list, just push it back onto the list at the appropriate index. For example, this code adds a string to the fifth list in the array:
std::vector<std::list<std::string> > nameListArray(20);