vendredi 22 septembre 2023

delete constructor in C++: private/protected/public?

what is the best practice to delete constructor in C++: put it in private/protected/public ?:

approach 1:

class Foo{
public:
Foo() = delete;
}

approach 2:

class Foo{
protected:
Foo() = delete;
}

approach 3:

class Foo{
private:
Foo() = delete;
}

Aucun commentaire:

Enregistrer un commentaire