While (1) {
Long double * a=new long double [2];
cout <& lt;" Array is a address: "& lt;
A [1]=2.0;
Long double * b=new long double [2].
cout <"Array b address:" & lt; cout <"[0] array b address:" & lt; <& B [0]
B [1]=4.0;
cout <"-- -- -- -- -- -- -- -- --" & lt;
cout <"Array b address:" & lt; cout <"[0] array b address:" & lt; <& B [0]
The delete [] b;
}
CodePudding user response:
You have a b=a so before b revealedCodePudding user response:
delete[] b;B=a;
Delete a;
CodePudding user response:
That b=a is I intentionally added, the solution already know, should be to define a long double but not to the assignment of pointer type, null pointer does not allocate memory, then the null pointer before b=a code point b, then the code is correct, neither in the code to run to the delete [] b when an error, nor a memory leak