CMPSC 24 Lecture Notes - Lecture 4: Null Pointer, Linked List
Document Summary
Implement a list of items arranged in some kind of order. Uses dynamic memory that grows and shrinks as needed. Memory locations of variables are scattered along memory. Where you store a data, you have to store a control information or link. The link is a pointer that points to address of the next node. Pointers to node itself (recursive data structure) class node{ private: double data; node *next; //pointing to another instance of type node main. cpp int main(){ node* head_ptr; //point to beg of list node* tail_ptr; //point to end of list. A special field when the pointer/link does not point to a legal node. Null ptr is used for the link field of the last node of a linked list. When the link does not have any nodes use null pts to represent empty list head_ptr = null; Using the node class cout << (*head_ptr). data(); cout << head_ptr->data();