How Many default methods does a class have?

In C++03 there are 4:

  • Default constructor: Declared only if
    no user-defined constructor is
    declared. Defined when used

  • Copy constructor – declared only if the user hasn’t declared one. Defined if used

  • Copy-assignment operator same as above

  • Destructor same as above

In C++11 there are two more:

  • Move constructor
  • Move-assignment operator

It is also possible that the compiler won’t be able to generate some of them. For example, if the class contains, for example, a reference (or anything else that cannot be copy-assigned), then the compiler won’t be able to generate a copy-assignment operator for you. For more information read this

Leave a Comment

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