Linked-List/Node/Iterator design

Hello,
In an attempt to create a basic generic linked-list class,
I am having a hard time deciding what the relationship between the List/Node/Iterator classes should be:
a) none of the classes mentioned satisfies the "Is-a" relationship in order be a a derived class.
b) I've been taught that using "friend" classes most often indicates bad programming.
c) I'm trying to minimize the public interface to include only methods which are necessary for List (such as list.insert()/list.begin() etc...)

It seems that trying to adhere to these 3 ideas, creates a conflict when attempting to create the list.

Is there any unanimous agreement on the correct design when creating a generic linked-list?

Thanks!
Each Node HAS the payload and links.

Each List HAS a pointer to the first Node (and possibly the last Node).

The ListIterator is a pointer to a Node.
The design you're suggesting here involves creating public methods for Node, which is not a stand-alone unit. I was thinking of creating
List : private Node<T>
so that list is-implemented-as Node,
and Node<T> is a class entirely 'protected'

Is this correct logic?
The design you're suggesting here involves creating public methods for Node
Not really, I was thinking about data structures not object interfaces.
Last edited on
Topic archived. No new replies allowed.