I'm not familiar with the "proper" terms to use describing what you need to do, but an overloaded operator+ member function should take a single argument. The "other" argument is the this pointer. To overload operator+ to take two arguments, the function should be moved outside of the class definition and be given the friend keyword.
You only need 1 argument because the 1st operand (before the + sign) is the bigint calling the function (this). The argument supplied is the 2nd operand - the one after the + sign.
I've tried this but I get a different error in my BigTest.cpp file.
The error states : 14 no matching function for call to `big::bigint::bigint(big::bigint)'
13 candidates are: big::bigint::bigint(big::bigint&)
BigTest.cpp:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#include<iostream>
#include"Bignum.h"
usingnamespace big;
usingnamespace std;
int main()
{
bigint big1, big2;
cout << "Enter a bigint.\n";
cin >> big1;
cout << "Enter a second bigint.\n";
cin >> big2;
cout << "Their sum is: " << big1+big2 << '\n';//error here
cout << "Congratulations!!!";
cin.get();
return 0;
}
Yes, I have successfully overloaded both insertion >>, and extraction << operators.
Your reference parameters should all be constant.
Hey, at first I didn't understand what you said, but I get it now, and it works. Now I just have to fix a small problem in my algo and then overload the other arithmetic operators.