How to delete the default constructor?

I would say make it private.. something like

class MyClass
{
private:
    MyClass();
}

and no one(from outside the class itself or friend classes) will be able to call the default constructor. Also, then you’ll have three options for using the class: either to provide a parameterized constructor or use it as a utility class (one with static functions only) or to create a factory for this type in a friend class.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)