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:
Ok, 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; }
to:Code:class BigInt{ int Num;
How do I change the overload operator functions to accomodate this??Code:class BigInt{ Node *Num;
Thanks!!



LinkBack URL
About LinkBacks


