#include <iostream>template<class T>class Node {public: Node() {next = NULL;} Node(T newData) {next = NULL; data = newData;} ~Node() {delete next;} void Add(T newData) { if (next) next->Add(newData); else next = new Node<T>(newData); } void Print() { std::cout << data << std::endl; if (next) next->Print(); } Node* next; T data;};//And an example of it's useint main(){ Node<int> list(1); list.Add(2); list.Add(3); list.Print(); system("PAUSE"); return 0;}
Not the most intuitive list ever, but it's templated which must count for something. Besides, it only took 5 minutes. It does use stl, but only for output. 19 lines, and almost readable.