#include <iostream>
usingnamespace std;
#include "HugeInteger.h"
HugeInteger::HugeInteger()
{
for (int i = 0; i <= MAX2; i++)
arr[i] = 0;
}
HugeInteger::HugeInteger(int op1[])
{
for (int i = 0; i <= MAX2; i++)
arr[i] = op1[i];
}
HugeInteger HugeInteger::operator + (const HugeInteger& right)
{
return (add(right));
}
HugeInteger HugeInteger::add(HugeInteger op2)
{
HugeInteger res;
int carry = 0;
for (int i = MAX2; i >= 0; i--)
{
res.arr[i] = arr[i] + op2.arr[i] + carry;
// arr[i] = arr[i] + op2.arr[i] + carry;
carry = 0;
while (res.arr[i] >= 10)
{
res.arr[i] -= 10;
carry++;
}
}
return (res);
}
booloperator == (const HugeInteger& exactEqual);
{
return(isEqualTo(exactEqual));
}
bool HugeInteger::isEqualTo(const HugeInteger& op2);
{
bool arrayEqual = false;
for (int i = 0; i < op2.MAX2; i++)
{
if(arr[i] == op.arr[i])
} arrayEqual = true;
return (arrayEqual);
}
Here's the error output:
HugeInteger.cpp:161:48: error: âbool operator==(const HugeInteger&)â must take exactly two arguments
HugeInteger.cpp:162:1: error: expected unqualified-id before â{â token
HugeInteger.cpp:166:51: error: declaration of âbool HugeInteger::isEqualTo(const HugeInteger&)â outside of class is not definition [-fpermissive]
HugeInteger.cpp:167:1: error: expected unqualified-id before â{â token
bool HugeInteger::isEqualTo(const HugeInteger& op2);
{ for (int i = 0; i < op2.MAX2; i++)
{ if(arr[i] != op2.arr[i])
returnfalse; // return immediately on miscompare. No point to continue
}
returntrue; // Can only be true if both arrays matched in the entirity.
}