I have a class, largeIntegers, that stores large numbers in an integer array as single digits and i am trying to overload the addition operator to add the two numbers, digit by digit but i can't get it to work.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
largeIntegers operator+(const largeIntegers& large) const//overloads addition operators for addition of two large numbers
{
largeIntegers tempInt;
for(int i = 0; i < large.digits; i++)
{
tempInt.number[i] = number[i] + large.number[i];
if(tempInt.number[i] >= 10)
{
tempInt.number[i] -= 10;
tempInt.number[i + 1] += 1;
}
}
return tempInt;
}
yes so in main you could just have instance1 + instance2 and get the summation of the two large numbers. btw the digits of the numbers have been fed into the array backwards so addition would be easier