-2

Is there any difference between a class with destructor and with out destructor.

e.g

class WithOut {    }
class With
{
    ~With(){}
}
stuartd
  • 66,195
  • 14
  • 128
  • 158
Dinesh Sharma
  • 117
  • 4
  • 5
  • 16

1 Answers1

1

Yes. From the documentation for Destructors:

Empty destructors should not be used. When a class contains a destructor, an entry is created in the Finalize queue. When the destructor is called, the garbage collector is invoked to process the queue. If the destructor is empty, this just causes a needless loss of performance.

Anon Coward
  • 7,460
  • 2
  • 19
  • 31