expand icon
book ADTs, Data Structures, and Problem Solving with C++ 2nd Edition by Larry Nyhoff cover

ADTs, Data Structures, and Problem Solving with C++ 2nd Edition by Larry Nyhoff

Edition 2ISBN: 978-0131409095
book ADTs, Data Structures, and Problem Solving with C++ 2nd Edition by Larry Nyhoff cover

ADTs, Data Structures, and Problem Solving with C++ 2nd Edition by Larry Nyhoff

Edition 2ISBN: 978-0131409095
Exercise 5
Exercises 1-7 assume the following declarations (which are used to process singly-linked lists as described in this section):
?class Node { public: int data; Node * next; }; Node * p1, * p2, * p3;
Assume also that the following statements have been executed:
?p1 = new(nothrow) Node; p2 = new(nothrow) Node; p3 = new(nothrow) Node;
Tell what will be displayed by each of the code segments or explain why an error occurs.
?p1- data = 12; p2- data = 34; p3- data = 34; p1- next = p2; p2- next = p3; p3- next = 0; cout p1- data " " p1- next- data endl; cout p2- data " " p2- next- data endl; cout p1- next- next- data endl; cout p3- data endl;
Explanation
Verified
like image
like image

Analysis:
When the program statement is...

close menu
ADTs, Data Structures, and Problem Solving with C++ 2nd Edition by Larry Nyhoff
cross icon