// 181/C++examples/huge/HugeInt.h =bds mods to // Fig. 8.8: hugeint1.h // Definition of the HugeInt class #ifndef HUGEINT_H #define HUGEINT_H #include class HugeInt { friend ostream &operator<<( ostream &, HugeInt & ); // new 11/98 -bds friend HugeInt operator+( int, HugeInt & ); // int + HugeInt friend HugeInt operator-( int, HugeInt & ); // int - HugeInt friend HugeInt abs( HugeInt & ); // absolute value public: HugeInt(); // default constructor HugeInt( HugeInt & ); // Copy constructor HugeInt( long ); // conversion constructor HugeInt( const char * ); // conversion constructor HugeInt operator+( HugeInt & ); // add another HugeInt HugeInt operator+( int ); // add an int HugeInt operator+( const char * ); // add an int in a char* // new 11/98 -bds HugeInt operator-( HugeInt & ); // subtract another HugeInt HugeInt operator-( int ); // subtract an int HugeInt operator-( const char * ); // subtract an int in a char* private: // parameters: Change SIZE and/or BASE to redefine "Huge". static const int SIZE; // max number of digits static const int BASE; // base of the arithmetic // These are derived from SIZE and BASE static const int MAX_INDEX; static const int HALF_BASE; static const int MAX_DIGIT; short* integer; // new 11/98 -bds void negate();// change sign void complement();// subtract from 10^SIZE void add1();// ++(*this) void debug( char* msg ); // debug prints msg followed by object data to cerr. }; #endif