When/why would I want to explicitly delete my constructor? Assuming the reason is to prevent its usage, why not just make it private?
class Foo
why explicitly delete the constructor?
Another reason:
I use delete when I want to assure that a class is called with an initializer.
I consider it as a very elegant way to achieve this without runtime checks.
The C++ compiler does this check for you.
class Foo
{
public:
Foo() = delete;
Foo(int bar) : m_bar(bar) {};
private:
int m_bar;
}
This - very simplified - code assures that there is no instantiation like this: Foo foo;