Joshua Joshua - 1 month ago 12
C++ Question

How to overload a destructor?

How do I overload a destructor?

Answer

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() { ... }
public:
  DestroyFoo(int) { ... };
  DestroyFoo(std::string) { ... }
};