The version of the class provided online in bigint.h has division and modulus operators implemented. These are not implemented in the class discussed in the case study so that teachers can make division a class project. However, the version provided here is also available online --- see the college board web page for details)
(http://cbweb1.collegeboard.org/ap/computer-science/html/indx001.html)
To determine the cause of each line of output you'll need to look both at the factorial program fact.cpp and at the implementation of the BigInt class in bigint.cpp. You should describe, for each constructor and destructor, the cause of the output. For example, the first line of output, "default constructor called" is caused by the definition of the variable answer in main.
User-entered input is in italics
prompt> fact default constructor called fact up to: 3 int constructor called num = 1 copy constructor called with 1 destructor called for 1 destructor called for 1 0! = 1 int constructor called num = 1 copy constructor called with 1 destructor called for 1 destructor called for 1 1! = 1 int constructor called num = 1 copy constructor called with 2 destructor called for 2 destructor called for 2 2! = 2 int constructor called num = 1 copy constructor called with 6 destructor called for 6 destructor called for 6 3! = 6 destructor called for 6
9! = 362880 int constructor called num = 1 copy constructor called with 3628800 destructor called for 3628800 destructor called for 3628800 10! = 3628800 int constructor called num = 1 int constructor called num = 11 copy constructor called with 3628800 int constructor called num = 0 copy constructor called with 3628800 copy constructor called with 3628800 destructor called for 3628800 destructor called for 3628800 copy constructor called with 36288000 copy constructor called with 36288000 destructor called for 36288000 destructor called for 36288000 destructor called for 39916800 destructor called for 362880000 destructor called for 11 copy constructor called with 39916800 destructor called for 39916800 destructor called for 39916800 11! = 39916800
copy the dividend to tempDiv set quotient to zero while tempDiv >= divisor subtract divisor from tempDiv increment quotient by oneUse this to implement the member function whose header is given below. For this problem assume that divisor and dividend are both positive (as with the AP test question).
BigInt & BigInt::operator /=(const BigInt & rhs) // postcondition: return BigInt / rhs after modification
#dig ^2 dig time 0 1 0 100 200 0.11 200 400 0.5 300 600 1.16 400 800 2.09 500 1000 3.3 600 1200 4.84 700 1400 6.48 800 1600 8.46 900 1800 10.66