list1 - // Set count (should initially be zero) } // -----...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
// ------------------------ List function definitions (list1.cpp) -------- #include "link1.h" // my linked list structure #include "list1.h" // my list function declarations // ----- Initialize the list. (Create an empty list.) void listinit() { public: node *root; // header/first node in linked list node *conductor; // pointer for traversing the linked list root = new node; // root points to a new node struct root->next = 0; // empty list (next pointer is NULL) } // ----- Append a new node to the end of the list. void listappend(double denomination, int count) { conductor->next = new node; // Create a new node at the end of the list conductor = conductor->next; // Point to that node conductor->damount = denomination; // Set denomination amount conductor->dcount = count;
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: // Set count (should initially be zero) } // ----- Move pointer (conductor) to FIRST node in the list. void listfirst() { conductor = root; // point to first node } // ----- Move pointer (conductor) to NEXT node in the list. bool listnext() { conductor = conductor->next; // Point to next node return true; // Returns true if successful, false otherwise } // ----- Update the count for the current node. void listupdatecount(int count) { conductor->dcount = count; // Set count } // ----- Return the denomination AMOUNT for the current node. double listamount() { return conductor->damount; // return the amount } // ----- Return the denomination COUNT for the current node. int listcount() { return conductor->dcount; // return the count }...
View Full Document

Ask a homework question - tutors are online