#ifndef __INTEGER #define __INTEGER // Integer class interface: support operations for large integers // // CONSTRUCTION: with (a) no initializer or (b) an int, // (c) or a String, or (d) another Integer // // ******************PUBLIC OPERATIONS********************* // =, +=, -=, /=, *= --> Usual assignment // +, -, *, / --> Usual binary arithmetic // <, <=, >, >=, ==, != --> Usual relational and equality // << and >> --> Input and output // String ToString( ) --> Return String equivalent // int IntValue( ) --> Return int equivalent // int * version #include #include "String.h" class Integer { public: // Constructors Integer( int InitialValue = 0 ); Integer( const String & InitialValue ); Integer( const Integer & Rhs ); // Default is not OK // Destructor (default is NOT OK) ~Integer( ) { delete [ ] TheDigits; } // Assignment Operators // Default operator= is NOT OK const Integer & operator= ( const Integer & Rhs ); const Integer & operator+=( const Integer & Rhs ); const Integer & operator-=( const Integer & Rhs ); const Integer & operator/=( const Integer & Rhs ); const Integer & operator*=( const Integer & Rhs ); // Mathematical Binary Operators Integer operator+( const Integer & Rhs ) const; Integer operator-( const Integer & Rhs ) const; Integer operator/( const Integer & Rhs ) const; Integer operator*( const Integer & Rhs ) const; // Relational and Equality Operators int operator< ( const Integer & Rhs ) const; int operator<=( const Integer & Rhs ) const; int operator> ( const Integer & Rhs ) const; int operator>=( const Integer & Rhs ) const; int operator==( const Integer & Rhs ) const; int operator!=( const Integer & Rhs ) const; // Unary Operators const Integer & operator++( ); // Prefix Integer operator++( int ); // Postfix const Integer & operator--( ); // Prefix Integer operator--( int ); // Postfix const Integer & operator+( ) const; Integer operator-( ) const; int operator!( ) const; // Member Functions String ToString ( ) const; int IntValue( ) const; // Friends of the class: privacy is waived for these friend ostream & operator<< ( ostream & Out, const Integer & Value ); friend istream & operator>> ( istream & In, Integer & Value ); private: int * TheDigits; int MaxDigits; int SignBit; int NumDigits; }; #endif