// main.cc P. Conrad, 5/16/05
// test copy constructor

#include "acct.h"
#include "acctList.h"

#include <iostream>
#include <fstream>

using namespace std;


int main()
{
  AcctList_C acctList1; // default constructor makes empty list

  Acct_C *p; // a pointer with which to allocate new accounts from heap
  p = new Acct_C(101,"Nixon");
  acctList1.addAccount(*p);

  p = new Acct_C(102,"Kennedy");
  acctList1.addAccount(*p);

  p = new Acct_C(103,"Ford");
  acctList1.addAccount(*p);

  cout << "Here is acctList1:" << endl;
  acctList1.printAllAccounts();
  cout << endl << endl;

  AcctList_C acctList2(acctList1); // this line invokes copy constructor

  cout << "Here is acctList2 (should be a copy of acctList1): " << endl;

  acctList2.printAllAccounts();
  cout << endl << endl;
  
  cout << "To show they are different, we add Carter to 1 and Reagan to 2\n"
       << "If default memberwise copy is used, lists won't be independent\n"
       << endl;

  acctList1.addAccount(Acct_C(201,"Carter"));
  acctList2.addAccount(Acct_C(301,"Reagan"));

  cout << "Here is acctList1 (should be same as before, plus Carter):" << endl;
  acctList1.printAllAccounts();
  cout << endl << endl;

  cout << "Here is acctList2 (should be same as before, plus Reagan):" << endl;
  acctList2.printAllAccounts();
  cout << endl << endl;

  return 0;

}







