here is the implementation for >> and operator+ for bigint
I appologize for not using the code tags (new here) and its been a very long week so im a little out of itCode:std::istream& operator>> (std::istream& in, bigint& num) { num.initialize(); char ch; in >> ch; while (ch != ';') { num.push_back(ch-'0'); in >> ch; } return in; } bigint bigint::operator+ (bigint rhs) const { bigint result; int rhs_max = rhs.size(); int lhs_max = size(); int max; if (rhs_max > lhs_max) max = rhs_max; else max = lhs_max; int idx = 0; int temp; while (idx < max) { temp = digits[idx] + rhs.digits[idx] + result.digits[idx]; int i = 0; while (temp != 0) { result.digits[idx+i] = (temp%10); temp = (temp/10); ++i; } ++idx; } return result; }




Reply With Quote