Hey folks, Im a newebie in c++ and I was working on operator overloading to figure out how they work but Im kinda stuck in not a cool problem (leading zeros).
I have bunch of arithmetic and IO overloaded operators, what I want to do is to suppress leading zero in my insert operator so the final calculated result is without any leading zeros.
I'm trying to edit the extract part to set the unused leading digits to zero since the array is filled via user input so for instance if some body put a digit string that is less than my DEFINE DIGITS 50 (like 5 + 6) the answer will be 11 (11 is two characters so far) plus 48 other funny non-sense characters.
The strategy is to set the null (unused) array elements to 0 (my loop counts backward in array so null elements are always leading elements in the array) so as we did earlier in extract operator those null elements which are now sat to be zero are suppressed in insert operator.
here is the extract operator (I come up with something but its not working!) :
1 2 3 4 5 6 7 8 9 10 11
std::istream& operator >>(std::istream& input, Bigint& number) {
string test ;
if (in >> test ) {
for (int i = DIGITS - 1; i >= 0; i--) {
}
}
return in;
}