It was a test question, which I got wrong.
I want to argue the
point, and need some expert ammunition.
When I think "deallocated" I'm talking about what happens to a
non-static object when it passes out of scope.
-=-
class MyThing
{
public:
MyThing();
~MyThing();
};
MyThing::MyThing()
{
//blah blah
};
MyThing::~MyThing()
{
//destruct destruct
};
void Func()
{
MyThing t;
}
int main()
{
Func();
return 0;
}
-=-
Here how I imagine things happening: in Func, MyThing is "allocated"
and the constructor runs. When Func is over, MyThing passes out of
scope ... First the destructor runs, to take care of anything that the
programmer needs taken care of. The last thing to happen is
"deallocation" of the space taken up by the object t. The thing that
happens right before "deallocation" is the destructor running.
Maybe I don't understand the word "deallocated" ... Maybe I don't
understand what happens when an object passes out of scope.