Linked List full of arrays
I want to make a Linked List containing arrays of size 26. In my .h file I declare it as this:
list <string*> root;
How would I initialize/do things with the inner array in the .cpp file? I'm just not sure how to access that information.
You can't have a list of arrays directly, but you can wrap them in a struct.
1 2 3
|
struct Array {
int values[26];
};
|
It would be a good idea to make this a template class and add operator [] to it, but I'll keep it simple.
You can then write
1 2 3 4 5 6
|
list<Array> lst;
Array a1 = {1, 2, 3};
lst.push_front(a1);
list<Array>::iterator i = lst.begin();
i->values[0] = 7;
//and etc.
|
tnx for the info
Topic archived. No new replies allowed.