perhaps this will simplify. below is the header and then the
implementation
#ifndef BIGINT_ABROWNIN
#define BIGINT_ABROWNIN
#include <iostream> //provides istream and ostream
#include <cstdlib> // provides size_t
namespace abrowning6 {
class BigInt {
public:
//TYPEDEFS and MEMBER CONSTANTS
typedef std::size_t size_type;
typedef int value_type;
static const size_type CAPACITY = 100;
//CONSTRUCTOR
BigInt ();
//MODIFICATION MEMBER FUNCTIONS
void insert(const value_type& entry);
void erase_all();
//CONSTANT MEMBER FUNCTIONS
size_type size() const { return used;}
bool is_item () const;
value_type current() const;
int getB1() const {return big_int1;}
int getB2() const {return big_int2;}
friend std:
stream & operator <<
(std:
stream & outs, const BigInt & source);
friend std::istream & operator >>
(std::istream & ins, const BigInt & target);
private:
value_type data[CAPACITY];
size_type used;
size_type current_index;
int sign;
int big_int1;
int big_int2;
};
// NONMEMBER FUNCTIONS for the big_int class
BigInt operator + (const BigInt& big_int1, const BigInt&
big_int2);
BigInt operator - (const BigInt& big_int1, const BigInt&
big_int2);
BigInt operator * (const BigInt& big_int1, const BigInt&
big_int2);
BigInt operator / (const BigInt& big_int1, const BigInt&
big_int2);
BigInt operator % (const BigInt& big_int1, const BigInt&
big_int2);
}
#endif //BIGINT_H
#include <cassert> //provides assert
#include "big_int.h"
#include <cstdlib>
#include <iostream>
namespace abrowning6 {
BigInt::BigInt()
:used(0),
current_index(0),
sign (+1),
big_int1(0),
big_int2(0)
{// Constructor has no work to do
}
const BigInt::size_type BigInt::CAPACITY;
void BigInt::insert(const value_type& entry){
assert (size() < CAPACITY);
data[used] = entry;
++ used;
}
void BigInt::erase_all(){
used = 0;
}
BigInt operator + (const BigInt& big_int1, const BigInt&
big_int2){
assert (big_int1.size() + big_int1.size() <= BigInt::CAPACITY);
return
big_int1 + big_int2;
}
BigInt operator - (const BigInt& big_int1, const BigInt& big_int2){
return
big_int1 - big_int2;
}
BigInt operator * (const BigInt& big_int1, const BigInt& big_int2){
assert (big_int1.size() * big_int2.size() <= BigInt::CAPACITY);
return
big_int1 * big_int2;
}
BigInt operator / (const BigInt& big_int1, const BigInt& big_int2){
return
big_int1 / big_int2;
}
BigInt operator % (const BigInt& big_int1, const BigInt&
big_int2){
BigInt modulus;
return
big_int1 % big_int2;
}
friend ostream & operator <<(ostream & outs, const BigInt&
big_int1){
outs << big_int1.get_b1() << " " << big_int1.get_b2();
return outs;
}
friend istream & operator >>(istream & ins, const BigInt&
big_int1){
ins >> target.big_int1 >> target.big_int2;
return ins;
}
}
1,5 Top