Question: What is wrong in the following code? double * p 1 = new double; double * p 2 = p 1 ; * p 2

What is wrong in the following code?
double*p1= new double;
double*p2=p1;
*p2=5.4;
delete p1;
cout *p2 endl;
p 1 and p 2 point to the same data, but it was destroyed using delete p 1. So you cannot access it later using *p2.
p1 got deleted
p 1 got deleted and p2 got deleted
None of the answer choices are correct
p1 does not have a value
What is wrong in the following code? double * p 1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!