/********************************************************************
 CS177/457 C++ Programming
 Fall 1998

 An abstract data type for large integers

 Your task is to write a class for very large integers, i.e. ones that
 do not have a size limitation, and can be any number of digits long.
 Your program will consist of a single class, and a main function that
 tests its capabilities.

 Your program must:
  1. be capable of representing integers of any length
  2. have constructors to initialize numbers with standard integers
     (type long int), and from a string of digits (e.g. "1234567890")
  3. have overloaded operators for addition (+) and multiplication (*)
  4. have an overloaded operator for assignment (=)

  You can use this skeleton for the class itself and for the global functions:

  class Bignum {
  private:
    // insert here your representation of a very large integer using a vector
  public:
    Bignum(); // default constructor
    Bignum(long n); // constructor for "small" integers
    Bignum(string n); // constructor for very large integers
    Bignum(const Bignum& n); // copy constructor
    Bignum add(const Bignum& r) const; // addition
    Bignum mult(const Bignum& r) const; // multiplication
    Bignum& operator=(const Bignum& r); // assignment
    ... 
  };
  
  // define overloaded operators with global functions
  ostream& operator<<(ostream& str, const Bignum& v) { ... }
  Bignum operator+(const Bignum& l, const Bignum& r) { ... }
  Bignum operator*(const Bignum& l, const Bignum& r) { ... }

  Hints and notes
  o Use a vector of unsigned char to hold the digits of the number--use
    push_back to add digits--store them in reverse order, e.g. the number
    12345 is stored as digits 5, 4, 3, 2, 1
  o Use const reference parameters in the implementations of the operators
    to avoid copying of the vector inside each object
  o Return *this at the end of assignment (=) operator
  o Return a reference to the stream at the end of the insertion (<<) operator
  o Use for loops, either forward or backward to process elements of the
    vectors
  o Implement member functions to do the work of the operations, and then
    global overloaded operators that call them. You will also need accessor
    functions for the private variable(s) in the class.

  Testing
  Your program should be able to succesfully compile and execute the
  following main function (assuming the name of the class is Bignum):
******************************************************************/
  int main() {
  Bignum t1, t2(321), t3("11223344556677889900"); // three different
                                                  // constructors
  Bignum t4(t2);  // copy constructor

  cout << "t1 is " << t1 << endl; // print the initial values
  cout << "t2 is " << t2 << endl;
  cout << "t3 is " << t3 << endl;
  cout << "t4 is " << t4 << endl;

  t1 = t4 * t3 + t3 * t2;  // arithmetic operators, and assignment

  cout << "t1 is " << t1 << endl;

  return 0;
}

/**********************************************************************
 DUE DATE: FRIDAY NOVEMBER 6th. BEFORE 5PM.
**********************************************************************/
