I was just reading this article and wanted SO folks advice:
Q: Should delete this; be called from within a member method?
I was just reading this article and wanted SO folks advice:
Q: Should delete this; be called from within a member method?
Although not directly related to this thread i wanted to clarify this. I was asked a question that given a situation:
int* a = new int ;
int* b = a ;
delete a;
Now is the next statement safe?
cout<<*b ;
My answer: After delete a, the location pointed to by a has been marked for deletion and at any point of time it can be assigned to some other object. Hence accessing the value using b is not safe as it may get modified after being allocated to some other object.
Note: No downvoting please, this is just a clarification