10-4. Write a class that implements a list that holds strings.
10-5. Write a bidirectional iterator for your String_list class.
10-6. Test the class by rewriting the split function to put its output into a String_list.

there are theses three exercises in the book I'm studying, what is it asking me to do ? to create a 'container' ? and how should I approach this ? any hints?

Recommended Answers

All 2 Replies

I am convinced that the exercise is in the wrong place in the book. The list class should be written as a linked list. It seems to me that a bi-derectional iterator should be a class (perhaps a subclass of the list) but in order to work you have to override the ++ and -- operators, and the book doesn't teach that until a later chapter. There are two other alternatives: (1) write the iterator as a class that does NOT accept ++ and -- but instead has .increment() and .decrement() methods. Or (2) implement the list under the hood as an array of strings (maybe this is what they wanted) in which case the iterator could simply be a pointer and it would work.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.