I’m wondering if I have 2 pointers pointing same object, and then I delete it using pointer 1, will it still be in memory and pointer 2 will point null, or object will stay in memory and I need to use delete pointer 2 to free it?
I mean:
int *p1, *p2;
p1=new int;
p2=p1;
*p1=5;
p2=p1;
delete p1;
int x=*p2;
//Error or x=5?
1 – Well, UB, not an “error” per se. But don’t do it.