Two problems associated with pointer types are dangling pointersand lost heap dynamic variables.
a) Briefly describe each of these problems and explain why it isconsidered a problem.
b) Consider the following code in C++:
int * a;
int * b = new int ;
a = b;
b = 5; b =6; b = 7;
int * c = new int;
// Asssume that deleted space for b is allocated to c.
c = 1; c = 2; c = 3;
a = 10 ; a = 11;
What are the values of c, c, and c after this codeexecutes? Explain.
c) Assume the code in part(b) is part of a subprogram thatterminnates immediately after the last statement (so there is no”delete c” statement). If this subprogram is called 20000 times,what is the effect on available memory in the heap, assuming eachint is four bytes long? Explain you answer.