What is wrong with the following code fragment?
Int *p1, *p2;
P1 = new int;
P2 = new int;
*p1=11;
*p2=0;
P2=p1;
Cout << *p1 <<" " << *p2 << endl;
Delete p1;
Delete p2;
A) nothing
B) p1 and p2 both have the same value, so the delete p2 will cause an error
C) You have a memory leak.
D) B and C
Correct Answer:
Verified
Q26: Given that p1 is a pointer variable
Q27: Which of the following is not true?
A)
Q28: What is the output of the following
Q29: Given that p1 is an integer pointer
Q30: If a program requires a dynamically allocate
Q32: Assuming that the pointer variable p1 is
Q33: Which of the following statements correctly prints
Q34: Given that p1 is a pointer, p1++
A)
Q35: Which of the following correctly declares a
Q36: If two pointer variables point to the
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents