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?
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'