-2

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

e.g

class WithOut {    }
class With
{
    ~With(){}
}
stuartd
  • 70,509
  • 14
  • 132
  • 163
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
  • 9,784
  • 3
  • 26
  • 37