CMPSC 24 Lecture Notes - Lecture 4: Null Pointer, Linked List

45 views2 pages
28 Feb 2018
School
Course
Professor

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();

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents