class Node { public: int data; Node * next; }; Node *p1, *p2, *p3; Assume also t
ID: 3626055 • Letter: C
Question
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 following code segments or explain why an error occurs.
Question # 3.
p1 -> data = 123;
p2 -> data = 456;
p1 -> next= p2;
p2 -> next= 0;
cout << p1 -> data << " " << p1 ->next->data << endl;
Question # 4.
p1 -> data = 123;
p2 -> data = 456;
p1 -> next= p2;
p2 -> next= 0;
cout << p2 -> data << " " << p2 ->next->data << endl;
Explanation / Answer
For the Question # 3, the p1 data is displayed but for the address, we need to write only coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.