Quote Originally Posted by Lindley View Post
Keep in mind that regardless of where the object itself is created, the object or one of its members may internally use heap memory.
Can you please explain this?

Also if the object is created on stack why do we need destructor? In the main(), objects would behave as automatic variable and get destroyed automatically right before the scope of main ends. In the same manner as for any other function.

E.g.
Code:
void f()
{
double d;
}
The object d gets destroyed automatically when the scope of function is over.