Question: Find the mistakes in the following code. Not all lines contain mistakes. Each line depends on the lines preceding it. Watch out for uninitialized
Find the mistakes in the following code. Not all lines contain mistakes. Each line depends on the lines preceding it. Watch out for uninitialized pointers, nullptr point- ers, pointers to deleted objects, and confusing pointers with objects. 1 int* p = new int; 2 p = 5; 3 *p = *p + 5; 4 strings = "Harry": 5 *s = "Sally"; 6 delete &s; 7 int* a = new int [10]; *a = 5; 8 9 a [10] = 5; 10 delete a; 11 int* q; 12 *q = 5; q = p; 14 delete q; 15 delete p; 13
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
