Top "Destructor" questions

A special method in object-oriented programming which is invoked when an object is destroyed

Php Destructors

Please give me some real life examples when you had to use __destruct in your classes.

php destructor
Unit testing destructors?

Is there any good way to unit test destructors? Like say I have a class like this (contrived) example: class …

c++ unit-testing destructor cppunit
Why is the destructor of the class called twice?

Apologies if the question sounds silly, I was following experts in SO and trying some examples myself, and this is …

c++ destructor
Under what circumstances are C++ destructors not going to be called?

I know that my destructors are called on normal unwind of stack and when exceptions are thrown, but not when …

c++ exception signals destructor exit
Static Finalizer

What is the right way to perform some static finallization? There is no static destructor. The AppDomain.DomainUnload event is …

c# .net static destructor finalizer
shared_ptr magic :)

Mr. Lidström and I had an argument :) Mr. Lidström's claim is that a construct shared_ptr<Base&…

c++ destructor smart-pointers
Why structs cannot have destructors?

What is best answer on interview on such question you think? I think I didn't find a copy of this …

c# .net struct destructor finalizer
Why is vector deleting destructor being called as a result of a scalar delete?

I have some code that is crashing in a large system. However, the code essentially boils down to the following …

c++ debugging visual-c++ msvcrt destructor
C++: Life span of temporary arguments?

When creating a new instance of a MyClass as an argument to a function like so: class MyClass { MyClass(int …

c++ destructor
Why destructor is not called on exception?

I expected A::~A() to be called in this program, but it isn't: #include <iostream> struct A { ~A() { …

c++ exception visual-c++ destructor stack-unwinding