#include <iostream.h>
#include "array.h"

main()
{
  Array<int> a;
  int i,j;

  cout << "Integer Array a initialized with zero elements.\n";
  cout << "Change array size to: ";
  cin >> i;

  a.resize(i);
  cout << "Integer array a now "<<a.size()<<" units.\n";
  cout << "Initializing values...";
  for(i = 0; i < a.size(); i++)
    a[i] = 100+i;

  cout <<"done\n";
  cout << "Contents of a:\n";
  for(i = 0; i < a.size(); i++)
    cout <<"a["<<i<<"] => "<<a[i]<<"\n";

  cout << "Change array size to: ";
  cin >> i;

  a.resize(i);
  cout << "Integer array a now "<<a.size()<<" units.\n";
  cout << "Initializing values...";
  for(i = 0; i < a.size(); i++)
    a[i] = 200+i;

  cout <<"done\n";
  cout << "Contents of a:\n";
  for(i = 0; i < a.size(); i++)
    cout <<"a["<<i<<"] => "<<a[i]<<"\n";
  

  Array<int> b;

  cout << "Integer Array b created.\nDuplicating a -> b.\n";
  b = a;

  cout << "Contents of b:\n";
  for(i = 0; i < b.size(); i++)
    cout <<"b["<<i<<"] => "<<b[i]<<"\n";

  cout << "About to index outside of bounds...\n";

  cout << "a[-10] => " << flush;
  cout << a[-10] << "\n";

  cout << "a[100000] => " << flush;
  cout << a[100000] << "\n";

  cout << "If you're reading this, then the bounds-checking failed.\n";
}

