-
array of structures
help, anyone???
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)
Code:
vector <string> nameList(20);
gives me one list of 20 elements, but i need 20 lists of x elements.
how could i go about this??
-
You want an array of vectors containing strings.
Code:
vector<string> nameListArray[20];
gg
-
Or ...
Code:
std::vector<std::list<std::string> > nameListArray(20);
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:
Code:
nameListArray[4].push_back("Mayce Edward");