Original Post
I was curious how the scope destruction of objects interacts with constructors and destructors, and new and delete.
The situation I am thinking of is this:
class a {
B* b;
}
a::a() {
b = new B();
}
a::~a() {
delete b
}
Now, when the constructor is called memory is allocated, but doesn't this get destroyed when it goes out of scope? If not, does dynamically allocated memory ever get destroyed by leaving scope? And also, if scope doesn't call delete, will the OS *ever* call delete on anything without me specifically calling it?
Thanks
[edited by - aargyle on April 24, 2003 11:33:46 AM]