The following code works well, it takes input from sample.txt which is just a list of five integers. The main, as you can see, just adds, subtracts, etc. Here is code, then I'll tell you what I want to change:
Code:
#include<iostream.h>
#include<fstream.h>
struct Node{
char digit;
Node *next;
};
class BigInt{
int Num;
public:
friend BigInt operator+(BigInt A, BigInt B);
friend BigInt operator-(BigInt A, BigInt B);
friend istream& operator>>(istream& in, BigInt &B);
friend ostream& operator<<(ostream& o, BigInt &B);
};
BigInt operator+(BigInt A, BigInt B)
{
A.Num += B.Num;
return A;
}
BigInt operator-(BigInt A, BigInt B)
{
A.Num -= B.Num;
return A;
}
istream& operator>>(istream& in, BigInt &B)
{
in >> B.Num;
return in;
}
ostream& operator<<(ostream& o, BigInt &B)
{
o << B.Num;
return o;
}
void main()
{
BigInt v1, v2, v3, v4, v5;
ifstream in;
in.open("sample.txt");
in >> v1 >> v2 >> v3 >> v4 >> v5;
cout << v1+v2 << endl;
cout << v3-v4 << endl;
}
Ok, I want to change:
Code:
class BigInt{
int Num;
to:
Code:
class BigInt{
Node *Num;
How do I change the overload operator functions to accomodate this??
Thanks!!