New blog location
   New blog location  
swapmoveFrom, if a new data member is added, both swap and moveFrom have to be modified. To avoid that, one can write the move constructor and move assignment operator with a default constructor and the swap function.class Bank { private: Bank() = default; }
cleanup() and moveFrom() can be removed. The destructor handles the code from cleanup. The code is as follows:Bank::Bank(Bank&& src) noexcept : Bank() { swap(*this,src); //Default constructor creates *this. } Bank& Bank::operator=(Bank&& rhs) noexcept { Bank temp(std::move(rhs)) //Need std::move because rhs is named swap(*this,temp); return *this; }
swap with move semanticsswap as seen below:void swap(T &a , T&b) { T temp(std::move(a)); a = std::move(b); b = std::move(temp); }
vector<CheckingAccount> instead of CheckingAccount*.private and protected static members of the class. If a reference to an object is passed in, they can also access private and protected non-static data members on objects of the same type.inline methods' definitions should be placed in a header file along with their prototypes.
Comments
Post a Comment