C++ | this pointer | Question 5
Predict the output of following C++ program?
(A) x = 0
(B) undefined behavior
(C) compiler error
Explanation: delete operator works only for objects allocated using operator new (See this post). If the object is created using new, then we can do delete this, otherwise behavior is undefined.
See “delete this” in C++ for more examples.
Quiz of this Question
My Personal Notes arrow_drop_up
Please Login to comment...