Create a class using an array to represent an integer of upto 40 digits, allow for basic math + - as well as multiplication = == < > etc

I am working on an assignemnet and I have some issues with my code it isn't compiling for me and I am a bit stumped.  I still need to add multiplication (which I am lost on) and equality operators but what i have is below. Essentially I need to use an array to store an integer of upto 40 digits and be able to perform basic operations on them.

Here is my code ifyou can help I'd appreciate it, been fighting with this for a little over a week.  Looked for other examples but none seemed to be doing it the same way I was.  they were using character arrays
-------------------------
#include <iostream>
#include <string>

using std::string;

class HugeInteger
{

public:
      
      HugeInteger( int startValue );
      HugeInteger( HugeInteger &operand2 );      
      HugeInteger addition( HugeInteger &operand2 );
      void setElement( const int index, const int newElement );
      void operator++();       
      string outputInteger();
      int getElement( int index );
      friend ostream &operator<<( ostream &output, HugeInteger &operand2 );
      friend istream &operator>>( istream &input, HugeInteger &operand2 );
      
      static const int SIZE= 40;

private:
      int bigInteger[SIZE];

};
------------------------------------------------------------
#include <iostream>
#include "HugeInteger.h"
#include <string>

using std::cout;
using std::endl;


HugeInteger::HugeInteger( HugeInteger &operand2 )
{
      for ( int i = 0; i < SIZE; i++ )
      {
            bigInteger[ i ] = &operand2.getElement( i );
      }
}

// Constructor that accepts a passed integer value
HugeInteger::HugeInteger( int passedValue )
{
      int newValue = passedValue;

      for ( int index = 0; index <= SIZE; index++ )
      {
            bigInteger[index] = 0;
      }

      if ( passedValue < 0 )
      {
            passedValue = 0;
      }

      for ( int index = SIZE - 1; index >= 0 ; index-- )
      {
            bigInteger[index] = newValue % 10;
            newValue /= 10;
      }
}

int HugeInteger::getElement( int element )
{
      if ( ( element < 0 ) || ( element > SIZE - 1 ) )
      {
            element = 0;
      }

      return bigInteger[element];
}

// Sets the index value of the array to newElement value
void HugeInteger::setElement( const int element, const int newElement )
{
      if ( ( element >= 0 ) && ( element < SIZE ) )
      {
            bigInteger[element] = newElement;
      }

      return;
}




void HugeInteger:operator++( )
{
      HugeInteger hugeInteger( 1 );

      cout << "*this: " << *this << endl;

      *this = (*this).addition( hugeInteger);

      cout << "*this: " << *this << endl;

      return;
}

// This function will addition to HugeIntegers together
HugeInteger HugeInteger::additionition( HugeInteger &operand2 )
{
      HugeInteger newHugeInt( 0 );
      int newElement = 0;
      int carry = 0;

      for ( int i = SIZE - 1; i >= 0; i-- )
      {
            newElement = bigInteger[ i ] + operand2.getElement( i ) + carry;

            // Once carry is used, reset to 0
            carry = 0;

            // Checks to see if newElement is greater than 10
            if ( newElement >= 10 )
            {
                  newElement = newElement - 10;
                  carry = 1;
            }

            // Sets new element into the HugeInteger
            newHugeInt.setElement( i, newElement );

      }


return newHugeInt;
}

ostream &operator<<( ostream &output, HugeInteger &operand2 )
{
      output << hugeInt.printHelper();

      return output;
}


string HugeInteger:printHelper()
{
      string output(" ");
      bool flag = false;

      for ( int i = 0; i < SIZE; i++ )
      {
            // check for null
            if ( ( bigInteger[ i ] == 0 ) && ( !flag ) )
            {
            }
            else
            {
                  flag = true;
                  char ch1[2];
                  ch1[0] = bigInteger[ i ] + '0';
                  ch1[1] = '\0';
                  string appendString(ch1);
                  output.append(appendString);
            }
      }


      return output;
}
urobinsAsked:
Who is Participating?
 
itsmeandnobodyelseConnect With a Mentor Commented:
>>>> using std::cout;
>>>> using std::endl;

Make

   using namespace std;

instead. With that you can omit std::  in the cpp.


>>>> std::istream& operator>>( istream &input, HugeInteger &operand2 );
>>>> {
>>>>
>>>> }

You have to remove the semicolon in the first line

You have to return at least the input you got.

istream& operator>>( istream &input, HugeInteger &operand2 )
{
      // todo make the streaming here

      return input;
}
 
0
 
Kent OlsenData Warehouse Architect / DBACommented:
Hi urobins,

What errors are you getting?

A few observations:

The HugeInteger method within the HugeInteger class is executed at instantiation.  You have two HugeInteger methods defined which suggests that you want to create a HugeInteger and initialize it based on an integer value or another HugeInteger value.  Is this correct?

I don't think that you really want:

  static const int SIZE = 40;


And I've also got reservations about:

  int bigInteger[SIZE];


Kent
0
 
urobinsAuthor Commented:
I am getting 40 errors so quite a few.  

Yeah I'd like to either create a blank object or be able to instantiate it with set number of elelments

II was thinking I should use a static to set the size of the array instead of dynamicaly but again I really don't have any idea :) I am open to any and all ideas to get this thing going :)
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
Kent OlsenData Warehouse Architect / DBACommented:
Hi Kdo,

One of the "gospels according to C programming" is that compilation errors need to be resolved from the first one encountered down.  It's often true that correcting one or two errors can eliminate dozens (or hundreds) of errors.

What are the first 5 or 6 errors?


Kent
0
 
urobinsAuthor Commented:
Here is the first block  Thanks for the help.  I am so sick of looking at this code :)

error C2143: syntax error : missing ';' before '&'
hugeinteger.h(18) : error C2433: 'ostream' : 'friend' not permitted on data declarations
hugeinteger.h(18) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
hugeinteger.h(18) : error C2061: syntax error : identifier 'ostream'
hugeinteger.h(18) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
hugeinteger.h(18) : error C2805: binary 'operator <<' has too few parameters
hugeinteger.h(19) : error C2143: syntax error : missing ';' before '&'
hugeinteger.h(19) : error C2433: 'istream' : 'friend' not permitted on data declarations
hugeinteger.h(19) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
hugeinteger.h(19) : error C2061: syntax error : identifier 'istream'
hugeinteger.h(19) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
hugeinteger.h(19) : error C2805: binary 'operator >>' has too few parameters
0
 
Kent OlsenData Warehouse Architect / DBACommented:
Hi urobins,

Try replacing the line

  using std::string;

with

  using namespace std;


Good Luck,
Kent
0
 
urobinsAuthor Commented:
okay that gets me to this, I don't know what an i-value is

hugeinteger.cpp(13) : error C2102: '&' requires l-value
hugeinteger.cpp(108) : error C2065: 'hugeInt' : undeclared identifier
hugeinteger.cpp(108) : error C2228: left of '.printHelper' must have class/struct/union
1>        type is ''unknown-type''
hugeinteger.cpp(114) : error C2039: 'printHelper' : is not a member of 'HugeInteger'
hugeinteger.h(7) : see declaration of 'HugeInteger'
hugeinteger.cpp(115) : error C2365: 'printHelper' : redefinition; previous definition was 'formerly unknown identifier'
test project 4\hugeinteger.cpp(119) : error C2065: 'SIZE' : undeclared identifier
test project 4\hugeinteger.cpp(122) : error C2065: 'bigInteger' : undeclared identifier
0
 
Kent OlsenData Warehouse Architect / DBACommented:
Hi urobins,

In the function headers, use '*' instead of '&'.


Good Luck,
Kent
0
 
itsmeandnobodyelseCommented:
>>>> In the function headers, use '*' instead of '&'.
No, the operators have to be defined with reference type and reference return.

It was the 'using' clause only what makes the errors.

Regards, Alex
0
 
urobinsAuthor Commented:
?????
0
 
Kent OlsenData Warehouse Architect / DBACommented:

Repost the source.  Let's see what you've got now.

0
 
urobinsAuthor Commented:
#include <iostream>
#include "HugeInteger.h"
#include <string>

using std::cout;
using std::endl;


HugeInteger::HugeInteger( HugeInteger &operand2 )
{
      for ( int i = 0; i < SIZE; i++ )
      {
            bigInteger[ i ] = &operand2.getElement( i );
      }
}

// Constructor that accepts a passed integer value
HugeInteger::HugeInteger( int passedValue )
{
      int newValue = passedValue;

      for ( int index = 0; index <= SIZE; index++ )
      {
            bigInteger[index] = 0;
      }

      if ( passedValue < 0 )
      {
            passedValue = 0;
      }

      for ( int index = SIZE - 1; index >= 0 ; index-- )
      {
            bigInteger[index] = newValue % 10;
            newValue /= 10;
      }
}

int HugeInteger::getElement( int element )
{
      if ( ( element < 0 ) || ( element > SIZE - 1 ) )
      {
            element = 0;
      }

      return bigInteger[element];
}

// Sets the index value of the array to newElement value
void HugeInteger::setElement( const int element, const int newElement )
{
      if ( ( element >= 0 ) && ( element < SIZE ) )
      {
            bigInteger[element] = newElement;
      }

      return;
}




void HugeInteger::operator++( )
{
      HugeInteger hugeInteger( 1 );

      cout << "*this: " << *this << endl;

      *this = (*this).addition( hugeInteger);

      cout << "*this: " << *this << endl;

      return;
}

// This function will addition to HugeIntegers together
HugeInteger HugeInteger::addition( HugeInteger &operand2 )
{
      HugeInteger newHugeInt( 0 );
      int newElement = 0;
      int carry = 0;

      for ( int i = SIZE - 1; i >= 0; i-- )
      {
            newElement = bigInteger[ i ] + operand2.getElement( i ) + carry;

            // Once carry is used, reset to 0
            carry = 0;

            // Checks to see if newElement is greater than 10
            if ( newElement >= 10 )
            {
                  newElement = newElement - 10;
                  carry = 1;
            }

            // Sets new element into the HugeInteger
            newHugeInt.setElement( i, newElement );

      }


return newHugeInt;
}

ostream &operator<<( ostream &output, HugeInteger &operand2 )
{
      output << hugeInt.printHelper();

      return output;
}


string HugeInteger::printHelper()
{
      string output(" ");
      bool flag = false;

      for ( int i = 0; i < SIZE; i++ )
      {
            // check for null
            if ( ( bigInteger[ i ] == 0 ) && ( !flag ) )
            {
            }
            else
            {
                  flag = true;
                  char ch1[2];
                  ch1[0] = bigInteger[ i ] + '0';
                  ch1[1] = '\0';
                  string appendString(ch1);
                  output.append(appendString);
            }
      }


      return output;
}

-----------------
#include <iostream>
#include <string>

using namespace std;

class HugeInteger
{

public:
      
      HugeInteger( int startValue );
      HugeInteger( HugeInteger &operand2 );      
      HugeInteger addition( HugeInteger &operand2 );
      void setElement( const int index, const int newElement );
      void operator++();       
      string outputInteger();
      int getElement( int index );
      friend ostream &operator<<( ostream &output, HugeInteger &operand2 );
      friend istream &operator>>( istream &input, HugeInteger &operand2 );
      
      static const int SIZE= 40;

private:
      int bigInteger[SIZE];

};
0
 
itsmeandnobodyelseCommented:
Some remarks:

A. HugeInteger.h

1. You should protect the header from being included twice

#ifndef HUGEINTEGER_H
#define HUGEINTEGER_H

// put her the current contents of the header

#endif

That matters if you add another header that included hugeinteger.h and have some cpp that includes both headers.

2. #include <string>

The string class wasn't used in the header. Then, you should omit the include.

3. using namespace std;

Omit that statement in the header. The using clauses should only be used in the .cpp files. That is to get conflicts when including third party libraries using the same names as in namespace std.

To prevent from compile errors you have to use the std:: prefix for STL classes in the header:

   friend std::ostream &operator<<( std::ostream &output, HugeInteger &operand2 );
   friend std::istream &operator>>( std::istream &input, HugeInteger &operand2 );

4. static const int SIZE= 40;

Some compilers do not accept const initializaion in class definition. You could use enum which was valid for all compilers:

   
      // static const int SIZE= 40;
      enum { SIZE = 40 };  // equivalent


B. HugeInteger.cpp

1. using std::cout;  using std::endl;

Here you can use

    using namespace std;

which is more comfortable.

2. bigInteger[ i ] = &operand2.getElement( i );

That is wrong syntax. You don't want to store the 'address'  (the & means the address) but the integer at position i.


     bigInteger[ i ] = operand2.getElement( i );


3. output << hugeInt.printHelper();

Must be

       output << operand2.printHelper();


4. output << operand2.printHelper();

The printHelper was not declared in the class definition.

You have to include <string>  (now it was needed!) and put the declaration to class HugeInteger:

   class HugeInteger
   {
           ...
           std::string printHelper();
 

That should compile.

Regards, Alex
0
 
urobinsAuthor Commented:
I made these changes and still have 21 errors.... I am  pretty confused at this point.  Am I addressing this properly?  Here is my current code.

#include <iostream>
#include "HugeInteger.h"
#include <string>

using std::cout;
using std::endl;


HugeInteger::HugeInteger( HugeInteger &operand2 )
{
      for ( int i = 0; i < SIZE; i++ )
      {
            bigInteger[ i ] = operand2.getElement( i );
      }
}

// Constructor that accepts a passed integer value
HugeInteger::HugeInteger( int passedValue )
{
      int newValue = passedValue;

      for ( int index = 0; index <= SIZE; index++ )
      {
            bigInteger[index] = 0;
      }

      if ( passedValue < 0 )
      {
            passedValue = 0;
      }

      for ( int index = SIZE - 1; index >= 0 ; index-- )
      {
            bigInteger[index] = newValue % 10;
            newValue /= 10;
      }
}

int HugeInteger::getElement( int element )
{
      if ( ( element < 0 ) || ( element > SIZE - 1 ) )
      {
            element = 0;
      }

      return bigInteger[element];
}

// Sets the index value of the array to newElement value
void HugeInteger::setElement( const int element, const int newElement )
{
      if ( ( element >= 0 ) && ( element < SIZE ) )
      {
            bigInteger[element] = newElement;
      }

      return;
}




void HugeInteger::operator++( )
{
      HugeInteger hugeInteger( 1 );

      cout << "*this: " << *this << endl;

      *this = (*this).addition( hugeInteger);

      cout << "*this: " << *this << endl;

      return;
}

// This function will addition to HugeIntegers together
HugeInteger HugeInteger::addition( HugeInteger &operand2 )
{
      HugeInteger newHugeInt( 0 );
      int newElement = 0;
      int carry = 0;

      for ( int i = SIZE - 1; i >= 0; i-- )
      {
            newElement = bigInteger[ i ] + operand2.getElement( i ) + carry;

            // Once carry is used, reset to 0
            carry = 0;

            // Checks to see if newElement is greater than 10
            if ( newElement >= 10 )
            {
                  newElement = newElement - 10;
                  carry = 1;
            }

            // Sets new element into the HugeInteger
            newHugeInt.setElement( i, newElement );

      }


return newHugeInt;
}

ostream &operator<<( ostream &output, HugeInteger &operand2 )
{
      output << operand2.printHelper();

      return output;
}


string HugeInteger::printHelper()
{
      string output(" ");
      bool flag = false;

      for ( int i = 0; i < SIZE; i++ )
      {
            // check for null
            if ( ( bigInteger[ i ] == 0 ) && ( !flag ) )
            {
            }
            else
            {
                  flag = true;
                  char ch1[2];
                  ch1[0] = bigInteger[ i ] + '0';
                  ch1[1] = '\0';
                  string appendString(ch1);
                  output.append(appendString);
            }
      }


      return output;
}
-----------------------
#include <iostream>


class HugeInteger
{

public:
      
      HugeInteger( int startValue );
      HugeInteger( HugeInteger &operand2 );      
      HugeInteger addition( HugeInteger &operand2 );
      void setElement( const int index, const int newElement );
      void operator++();       
      std::string printHelper();
      int getElement( int index );
      friend std::ostream &operator<<( ostream &output, HugeInteger &operand2 );
      friend std::istream &operator>>( istream &input, HugeInteger &operand2 );
      
      static const int SIZE= 40;

private:
      int bigInteger[SIZE];

};

0
 
itsmeandnobodyelseCommented:
>>>> I made these changes and still have 21 errors....

Hmmm. You didn't apply the changes I suggested properly ...

The problems were in the header.

1. in the header was no header protection
2. You didn't include <string> what I described in B4.
3. ostream and istream *arguments* must be declared with std:: prefix
4. (change 'static const int SIZE= 40;' to 'enum (SIZE = 40);'

The point 4 is not essential if you get noc compiler error.

point 1 is essential if including the hugeinteger.h in another header.

point 2: <string> must be included when you were using std::string as a return type. Here I first thought you don't need it, but later it turns out that you have functions returning a string.

point 3: copy the istream and ostream functions I posted.


As it is an assignment I cannot post you full code. But I compiled your code with my changes and there is nothing left if you apply what I told with A 1/2/3/4 and B 1/2/3/4
in the previous comment.

0
 
urobinsAuthor Commented:
Sorry, let me try again :)  I must not have saved changes before shutting down and coming into work :)
0
 
urobinsAuthor Commented:
Sorry, but I must be missing something or misinterpreting what you're suggesting.  here is what I have.  I am getting 19 errors, I know I'm missing something... Thanks so much for your help.

#include <iostream>
#include "HugeInteger.h"
#include <string>

using std::cout;
using std::endl;


HugeInteger::HugeInteger( HugeInteger &operand2 )
{
      for ( int i = 0; i < SIZE; i++ )
      {
            bigInteger[ i ] = operand2.getElement( i );
      }
}

// Constructor that accepts a passed integer value
HugeInteger::HugeInteger( int passedValue )
{
      int newValue = passedValue;

      for ( int index = 0; index <= SIZE; index++ )
      {
            bigInteger[index] = 0;
      }

      if ( passedValue < 0 )
      {
            passedValue = 0;
      }

      for ( int index = SIZE - 1; index >= 0 ; index-- )
      {
            bigInteger[index] = newValue % 10;
            newValue /= 10;
      }
}

int HugeInteger::getElement( int element )
{
      if ( ( element < 0 ) || ( element > SIZE - 1 ) )
      {
            element = 0;
      }

      return bigInteger[element];
}

// Sets the index value of the array to newElement value
void HugeInteger::setElement( const int element, const int newElement )
{
      if ( ( element >= 0 ) && ( element < SIZE ) )
      {
            bigInteger[element] = newElement;
      }

      return;
}




void HugeInteger::operator++( )
{
      HugeInteger hugeInteger( 1 );

      cout << "*this: " << *this << endl;

      *this = (*this).addition( hugeInteger);

      cout << "*this: " << *this << endl;

      return;
}

// This function will addition to HugeIntegers together
HugeInteger HugeInteger::addition( HugeInteger &operand2 )
{
      HugeInteger newHugeInt( 0 );
      int newElement = 0;
      int carry = 0;

      for ( int i = SIZE - 1; i >= 0; i-- )
      {
            newElement = bigInteger[ i ] + operand2.getElement( i ) + carry;

            // Once carry is used, reset to 0
            carry = 0;

            // Checks to see if newElement is greater than 10
            if ( newElement >= 10 )
            {
                  newElement = newElement - 10;
                  carry = 1;
            }

            // Sets new element into the HugeInteger
            newHugeInt.setElement( i, newElement );

      }


return newHugeInt;
}

std::ostream& operator<<( ostream &output, HugeInteger &operand2 )
{
      output << operand2.printHelper();

      return output;
}

std::istream& operator>>( istream &input, HugeInteger &operand2 );
{

}

string HugeInteger::printHelper()
{
      string output(" ");
      bool flag = false;

      for ( int i = 0; i < SIZE; i++ )
      {
            // check for null
            if ( ( bigInteger[ i ] == 0 ) && ( !flag ) )
            {
            }
            else
            {
                  flag = true;
                  char ch1[2];
                  ch1[0] = bigInteger[ i ] + '0';
                  ch1[1] = '\0';
                  string appendString(ch1);
                  output.append(appendString);
            }
      }


      return output;
}
----------------


#ifndef HUGEINTEGER_H
#define HUGEINTEGER_H

#include <iostream>


class HugeInteger
{

public:
      
      HugeInteger( int startValue );
      HugeInteger( HugeInteger &operand2 );      
      HugeInteger addition( HugeInteger &operand2 );
      void setElement( const int index, const int newElement );
      int getElement( int index );      
      std::string printHelper();
      void operator++();       
      friend std::ostream &operator<<( ostream &output, HugeInteger &operand2 );
      friend std::istream &operator>>( istream &input, HugeInteger &operand2 );
      
      //static const int SIZE= 40;
      enum { SIZE = 40 };

private:
      int bigInteger[SIZE];


};
#endif
0
 
itsmeandnobodyelseCommented:
>>> #ifndef HUGEINTEGER_H
>>> #define HUGEINTEGER_H

>>> #include <iostream>

Here you have to add

#include <string>

below #include <iostream>


>>>> friend std::ostream &operator<<( ostream &output, HugeInteger &operand2 );
Here the std:: is missing

      (std::ostream &output


>>>> friend std::istream &operator>>( istream &input, HugeInteger &operand2 );

Here the std:: is missing

      (std::istream &input


0
 
urobinsAuthor Commented:
doh! I'll make those now!  Thanks!
0
 
urobinsAuthor Commented:
Okay I changed those locations. Do I need to at the std:: to the .cpp functions as well?  I still get six errors I am getting.
hugeinteger.cpp(106) : error C2065: 'ostream' : undeclared identifier
hugeinteger.cpp(106) : error C2065: 'output' : undeclared identifier
hugeinteger.cpp(106) : error C2065: 'operand2' : undeclared identifier
hugeinteger.cpp(106) : error C2275: 'HugeInteger' : illegal use of this type as an expression

Any ideas?
Here is my code with what i believe were the corrections you recommended

#include <iostream>
#include "HugeInteger.h"
#include <string>

using std::cout;
using std::endl;


HugeInteger::HugeInteger( HugeInteger &operand2 )
{
      for ( int i = 0; i < SIZE; i++ )
      {
            bigInteger[ i ] = operand2.getElement( i );
      }
}

// Constructor that accepts a passed integer value
HugeInteger::HugeInteger( int passedValue )
{
      int newValue = passedValue;

      for ( int index = 0; index <= SIZE; index++ )
      {
            bigInteger[index] = 0;
      }

      if ( passedValue < 0 )
      {
            passedValue = 0;
      }

      for ( int index = SIZE - 1; index >= 0 ; index-- )
      {
            bigInteger[index] = newValue % 10;
            newValue /= 10;
      }
}

int HugeInteger::getElement( int element )
{
      if ( ( element < 0 ) || ( element > SIZE - 1 ) )
      {
            element = 0;
      }

      return bigInteger[element];
}

// Sets the index value of the array to newElement value
void HugeInteger::setElement( const int element, const int newElement )
{
      if ( ( element >= 0 ) && ( element < SIZE ) )
      {
            bigInteger[element] = newElement;
      }

      return;
}




void HugeInteger::operator++( )
{
      HugeInteger hugeInteger( 1 );

      cout << "*this: " << *this << endl;

      *this = (*this).addition( hugeInteger);

      cout << "*this: " << *this << endl;

      return;
}

// This function will addition to HugeIntegers together
HugeInteger HugeInteger::addition( HugeInteger &operand2 )
{
      HugeInteger newHugeInt( 0 );
      int newElement = 0;
      int carry = 0;

      for ( int i = SIZE - 1; i >= 0; i-- )
      {
            newElement = bigInteger[ i ] + operand2.getElement( i ) + carry;

            // Once carry is used, reset to 0
            carry = 0;

            // Checks to see if newElement is greater than 10
            if ( newElement >= 10 )
            {
                  newElement = newElement - 10;
                  carry = 1;
            }

            // Sets new element into the HugeInteger
            newHugeInt.setElement( i, newElement );

      }


return newHugeInt;
}

std::ostream& operator<<( ostream &output, HugeInteger &operand2 )
{
      output << operand2.printHelper();

      return output;
}

std::istream& operator>>( istream &input, HugeInteger &operand2 );
{

}

string HugeInteger::printHelper()
{
      string output(" ");
      bool flag = false;

      for ( int i = 0; i < SIZE; i++ )
      {
            // check for null
            if ( ( bigInteger[ i ] == 0 ) && ( !flag ) )
            {
            }
            else
            {
                  flag = true;
                  char ch1[2];
                  ch1[0] = bigInteger[ i ] + '0';
                  ch1[1] = '\0';
                  string appendString(ch1);
                  output.append(appendString);
            }
      }
-------------------------
#ifndef HUGEINTEGER_H
#define HUGEINTEGER_H

#include <iostream>
#include <string>

class HugeInteger
{

public:
      
      HugeInteger( int startValue );
      HugeInteger( HugeInteger &operand2 );      
      HugeInteger addition( HugeInteger &operand2 );
      void setElement( const int index, const int newElement );
      int getElement( int index );      
      std::string printHelper();
      void operator++();       
      friend std::ostream &operator<<( std::ostream &output, HugeInteger &operand2 );
      friend std::istream &operator>>( std::istream &input, HugeInteger &operand2 );
      
      //static const int SIZE= 40;
      enum { SIZE = 40 };

private:
      int bigInteger[SIZE];


};
#endif
0
 
urobinsAuthor Commented:
Thanks, I'll give this a shot.
0
 
urobinsAuthor Commented:
Thanks!  Got me compiling!  Now to actually make it work :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.