function.h #ifndef HUGEINTEGER_H
#define HUGEINTEGER_H
#include <iostream>
#include <string>
class HugeInteger
{
public:
HugeInteger();
HugeInteger( const std::string &);
/* addition operator overloading for “HugeInteger + HugeInteger”*/
/* addition operator overloading for “HugeInteger + string that represents a large integer value”*/
/* subtraction operator overloading for “HugeInteger – HugeInteger”*/
/* subtraction operator overloading for “HugeInteger - string that represents a large integer value”*/
/* multiplication operator overloading for “HugeInteger * HugeInteger”*/
/* multiplication operator overloading for “HugeInteger * string that represents a large integer value”*/
/* division operator overloading for “HugeInteger / HugeInteger”*/
/* division operator overloading for “HugeInteger / string that represents a large integer value”*/
/* relational operator overloading for “HugeInteger > HugeInteger”*/
/* stream insertion operator “<<” overloading*/
private:
int integer[42];
int noOfDigits;
};
#endifmain.cpp#include <iostream>
#include "function.h"
using namespace std;
int main() {
char c[2], a[42], b[42];
HugeInteger result,resultWithString;
while ( cin>>c>>a>>b ) {
HugeInteger n1(a);
HugeInteger n2(b);
if(c[0] == '+') {
result = n1+n2;
resultWithString = n1+b;
cout<<result<<endl<<resultWithString<<endl;
} else if(c[0] == '-') {
result = n1-n2;
resultWithString = n1-b;
cout<<result<<endl<<resultWithString<<endl;
}else if(c[0] == '*') {
result = n1*n2;
resultWithString = n1*b;
cout<<result<<endl<<resultWithString<<endl;
}else if(c[0] == '/') {
result = n1/n2;
resultWithString = n1/b;
cout<<result<<endl<<resultWithString<<endl;
} else if (c[0] == '>') {
cout<< (n1>n2) <<endl;
} else {
cout<<"ERROR";
return 0;
}
}
return 0;
} // end main
There are three strings in each line: S1 S2 S3
S1 represents an operator (+, -, *, /, >).
S2 and S3 represent the two positive huge-number operands.
For subtract operation, S2 is always no less than S3.
Input terminated by EOF.
For every given operation, your program should print the corresponding result followed by a new line character.