//************************************** // // link class head file // // // PROJECT NAME: LINK // // YOUR NAME: XYZ // YOUR ID: 1234 // YOUR EMAIL: xyz@cs.ucr.edu // //************************************** #ifndef _link_h_ //prevent multi-including this head file #define _link_h_ #include using namespace std; //specify using "std" namespace //declare our own class class element; class list; typedef int element_type; // Define element_type as "int" type. // You can change "int" to other types // in order to change the element_type. //************************************************** // Declare variables and functions in class element //************************************************** class element { private: element_type value; // the value of the current element element *next; // pointer of the next element public: element(); // constructor //~element(); element(element_type v); // another type of constructor element_type getValue(); // get the value of current element void setValue(element_type v); //set the value of current element void makeNext(element *a); // set the link to the next element element * getNext(); // get the address of the next element element * print(); // print out the value of current element }; //************************************************** // Declare variables and functions in class list //************************************************** class list { private: element *head; // a pointer which point to the head of the list public: list(); // constructor element *popElement(); //pop out the head element void addElement(element_type val); // add a element to the list void print(); //print out }; #endif