/* uses the class BigInt that Program 5 is based on. Readin in 10 BigInt objects into an array and prints them out. */ #include #include class BigInt{ private: /* This is the syntax to have a const data member of a class. */ static const int NUM_DIGITS = 20; int num[NUM_DIGITS]; public: void read_num(ifstream&); /* reads in an integer from the input file */ void print_num(); /* prints out the integer to the screen */ // BigInt sum(BigInt); /* You should implement this function below. */ }; void BigInt::read_num(ifstream& infile){ int a[NUM_DIGITS], i,j; char inp; /* skip everything before the first integer starts */ do infile.get(inp); // similar to infile >> inp, but doesn't // skip over white space. while (inp<'0' || inp>'9'); a[0] = inp - '0'; for(i=1; i=0; i--){ if (num[i]) initialzero = false; if (!initialzero || i==0) cout << static_cast(num[i]+'0'); } } void main(){ ifstream infile("bignums.dat"); /* this declares the object infile */ BigInt n[10]; for (int i=0; i<10; i++){ n[i].read_num(infile); n[i].print_num(); cout << endl; } }