For each of these statements, draw a diagram showing what happens to the memory locations.
ITEM *p, *s, *r;
ITEM x;
p = new ITEM;
s = p;
r = NULL;
s = &x;
delete p;
p = 0;
{ int *a, *b, *c; a = new int; *a = 10; b = a; c = new int; *c = *a; cout << setw(4) << *a << *b << *c << endl; *a = 23; cout << setw(4) << *a << *b << *c << endl; delete b; delete c; }
struct node { int data; node*next; }; int main ( ) { node *s, *t; s = new node; s -> data = 12; t = new node; t -> next = s; t -> data = 23; s -> next = NULL; delete t; delete s; return 0; }
node *p, *s;
p = new node;
s = new node;
p -> data = 5;
s -> data = 6;
delete p;
p = s;
p ->data = 1;
cout << p ->data << " " << s ->data;
delete p;
p = NULL;
node *p, *s;
p = new node;
p ->data = 3;
s = new node;
s ->data = 2;
p = new node;
p ->data = s ->data;
s ->data = 0;
s ->next = NULL;
p ->next = s;
cout << p ->data << " " << s ->data;
delete p;
delete s;