CS 1337 Lecture Notes - Lecture 21: Standard Template Library, Linked List
Document Summary
The last node in the list points to the first node of the list linked lists are also available. // description : hello world in c++, ansi-style. * standard template library class mylist { public: * one or more data fields i want to store. * payload of the node, the data stored in node double data; * signify empty list by having the head point to nullptr. Node *head = nullptr; void add(double d) { Node *curr; curr = head; while(curr != nullptr) cout << curr->data << endl; curr = curr->next; void append(double d) { //iterate to find the end of the list. Node *prev; curr = head; prev = nullptr; while(curr != nullptr) Node *newnode = new node; newnode->data = d; prev = curr; curr = curr->next; newnode->next = prev->next; //nullptr prev->next = newnode; if(prev != nullptr) { else { newnode->next = nullptr; head = newnode;