I think you may be looking at this backwards. A destructor does not destroy an object. A destructor is called when an object is being destroyed.
In the case of statically declare objects (on the stack), consider the following code fragment
1 2 3 4 5 6 7 8 9 10
|
if (x == true)
{
int a = 4;
int b = 6;
MyClass object1;
object1.function1(a);
object1.function2(b);
}
// object1 is no longer available.
...
|
When the function hits the "if" statement at the beginning, a new object of type MyClass is put on the stack. This means that memory (the size of MyClass) for the object is allocated in the next stack frame and given the name "object1". The integer values a and b are also allocated on the stack.
Some member functions are called on object1, and then the curly brace at the end closes the scope of the "if" statement. At this curly brace, before the"object1 is no longer available" line, a, b and object1 all leave scope, and are destroyed. Nothing happens to the memory allocated on the stack (until the another allocation occurs), but the program cannot access those objects any more. As the object leaves scope, it is destroyed, and the destructor is called. This is especially helpful if the object allocated dynamic memory on the heap (or some other resource) and needs to release it.
When an object is allocated on the heap (with "new"), the life of the object is not dictated by scope of the code. The object lives until "delete" is called. At that point the object is destroyed and the destructor is called.