Answer Posted / hitout
There are different cases to this
1) If the memory is allocated in stack, delete this should
not be called since it calls destructor twice.
2) delete this can be called in all functions except
destructor if the memory is allocated on heap(ie if new
operator is used and the object is not explicitly deleted).
3) Delete this in destructor will always cause an infinite loop.
Is This Answer Correct ? | 6 Yes | 1 No |
Post New Answer View All Answers
What data encapsulation is in c++?
How can you link a c++ program to c functions?
Why do we need c++?
What is dev c++ used for?
When do we use copy constructors?
What is c++ manipulator?
How delete [] is different from delete?
What is std namespace in c++?
What is buffer and example?
Comment on assignment operator in c++.
How a pointer differs from a reference?
What is the purpose of ios::basefield in the following statement?
write a function signature with various number of parameters.
Can we make copy constructor private in c++?
What is a syntax in c++?