I've seen a constructor = delete explanation here but I'm wondering if I should forbid destructor calls as well. I'm trying to use a class like this:
class A
{
public:
static bool foo(const char* filePath);
static void foo(const int something);
private:
A() = delete;
~A();
};
Should I also write like ~A() = delete;
as well? Does it even matter?
~A() = delete;
is redundant, because since you cannot create an object, there is no point of worrying about destructor.
In fact with your code even there is no need of A() = delete;
, because all the class members are static
.
As Luchian rightly mentioned in the comment, such class
are better be declared as a namespace
. Underlying data can be made extern
/ static
depending on the requirement.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With