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
{
public:
Foo() = delete;
};
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
How about:
versus
They’re basically different things.
privatetells you that only members of the class can call that method or access that variable (or friends of course). In this case, it’s legal for astaticmethod of that class (or any other member) to call aprivateconstructor of a class. This doesn’t hold for deleted constructors.Sample here.