// main2.cc P. Conrad, 5/16/05
// test overloaded = operator

#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; // default constructor; empty list
  acctList2 = acctList1; // assignment operator

  AcctList_C acctList3 = acctList1; // uses copy constructor

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

  acctList2.printAllAccounts();
  cout << endl << endl;

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

  acctList3.printAllAccounts();
  cout << endl << endl;

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

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

  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;

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


  return 0;

}







