CS202   3- ‹#›
naccount::account(const char* n, float b) : balance(b) {
n  name = new char[strlen(n) + 1];
n  strcpy(name, n);
n}
naccount::account(const account &a) {
n  balance = a.balance;
n  name = new char[strlen(a.name) + 1];
n  strcpy(name, a.name);
n  cout <<"account copy constructor called" <<endl;
n}
naccount::~account() { delete[] name; }
naccount &account::operator=(const account &a) {
n  if (this != &a) {
n    balance = a.balance;
n    delete[] name;
n    name = new char[strlen(a.name) + 1];
n    strcpy(name, a.name);
n  }
n  cout <<"account assignment op called" <<endl;
n  return(*this);
n}
n
Dyn. Mem - Page 2 of 3