1.

What Are The Effects After Calling The Delete This Operator ?

Answer»

It is difficult for the compiler to KNOW whether an object is allocated on a stack or a heap. On INVOKING the delete this operator, the destructor is CALLED twice on the object related to the current context. Firstly implicitly and SECONDLY explicitly. It results in undefined behavior and error-prone conditions. The delete this operator can only WORK on three conditions:

  •  An Instantiation of a local variable should not take place, after calling the delete this destructor.
  •  The this pointer should not be used after calling the delete this operator.
  •  The object of a derived class should be allocated and initialized with the new operator

It is difficult for the compiler to know whether an object is allocated on a stack or a heap. On invoking the delete this operator, the destructor is called twice on the object related to the current context. Firstly implicitly and secondly explicitly. It results in undefined behavior and error-prone conditions. The delete this operator can only work on three conditions:



Discussion

No Comment Found