// Linked list as a class #ifndef _MYLIST_H_ #define _MYLIST_H_ #include using namespace std; template class MyList { public: // No constructor is defined - this assumes we don't need copy // semantics, so we won't assign MyList or pass them by value // Destructor ~MyList(); // Public methods of the list void append(T n); // Add a value to the end of the list void insert(T n, int position); // Insert a value at specified position void remove(T n); // Remove occurrences of this value void display() const; // Print the list private: // Nested private class for a node in the list class Node { public: Node() : _next(NULL) { } Node(T v, Node * np = NULL) : _value(v), _next(np) { } T value() const { return _value; } Node * next() const { return _next; } Node * next(Node * node) { return _next = node; } private: T _value; // Data value of this item in the list Node * _next; // Pointer to next item in list }; Node head; // The head of the list }; #include "MyList.c" #endif