//node.h //the links for a linked list //These nodes hold integers as data. //Other classes could be substituted //with minor modifications, as long as //they had the necessary operations. #ifndef NODE_H #define NODE_H #include #include using namespace std; class Node { public: Node(int i, Node * n=0); //puts the value, i, in the //data portion of the node // n=0 is a default function value; ~Node(); setNext(Node * n); //places address, n, in the //arrow portion of the node Node * getNext(); //returns an arrow to the next node int getData(); //returns the data private: int theData; //this could be another type //that is, in some applications we might //have nodes that hold objects of some other //class Node * theNext; //notice you can have a //pointer to the same type of object //you are defining. friend ostream& operator<<(ostream& out, Node& n); //Use reference for n so //we don't have to make //another copy. //Add data to output stream. friend istream& operator>>(istream& in, Node& n); //Use &n so n's value changes. };//end Node #endif