...

/

More Kinds of Constructors

More Kinds of Constructors

After the default and parameterized constructors, we will study a few more constructor types that make classes more convenient.

Copy constructors #

The copy constructor allows a class to create an object by copying an existing object.

They expect a constant reference to another instance of the class as their argument.

class Account{
public:
    Account(const Account& other);
};

All the values of other can be copied into the new object. Both objects will have the same values afterward.

Move constructors #

The ...