Hi guys! I have a question for you. I'm studying programming alone so I don't know who else to ask. Now I'm on the chapter about Linked Lists. There is and exercise in which I need to use Linked List in another Linked List. But the example that is shown in my book is too complicated and not understandable. It says to define a new name of a type for lists: define List<int> Dlist;
and with this I'm supposed to make this List: List<Dlist> A;
I think it's a bit longer to say all I have to say here so I would better ask you how you would do this task. Also I will be thankful if you can give me a good source to read about this type of tasks. :)
Let's change the question. Let's say that I define a new type: define List<int> Dlist;
Then if I try to use a function which is not a member in the class of the list it gives me error if I try to use the data of the node because the data members of the class are private:
1 2 3 4
void func(Dlist A, Dlist B)
List<T> *temp = B.start_ptr;//Error when I try to get the starting point of the list
So my new question is how is this supposed to be solved? Is there any way?
Here's a little code snippet to get your feet wet, as ne555 pointed out, we use iterators. You can refer to the documentation on this website or en.cppreference.com about linked lists. ne555 also mentions something I believe is important: to not mess with the insides. You are given this class and you have a high degree of freedom in using it, if you want more raw access you should code your own list class imho.