Joshua Joshua - 7 months ago 78
C++ Question

How to overload a destructor?

How do I overload a destructor?


You can't. There is only one destructor per class in C++.

What you can do is make a private destructor and then have several public methods which call the destructor in new and interesting ways.

class Foo {
  ~Foo() { ... }
  DestroyFoo(int) { ... };
  DestroyFoo(std::string) { ... }