Q1. What happens first- memory allocation or constructor call for the below written statement ?
int *ptr = new int();
Q2. What is the difference between following three approaches?
- If an object is destroyed with DELETE operator. Will destructor be called?
- If a destructor is called explicitly (e.g. a1.~A()) to destroy the object?
- Neither explicit destructor call is made nor DELETE operator is used to destroy the object but object goes out of scope.
What would be the behavior if the destructor is private or protected?