這是我的代碼爲我的運營商>>重載。它應該把數字分成一個分號並把它們放入一個bigint中。Bigint運營商>>超載
std::istream& operator>>(std::istream& is, bigint& bi) {
int i = 0;
char ch;
char temp[SIZE];
// grabs the first character in the file
is >> ch;
temp[i] = ch;
++i;
// while loop grabs the rest of the characters
// up to the semicolon
while(ch != ';') {
is >> ch;
temp[i] = ch;
++i;
}
// temp is stored in the bigint ref
bi = bigint(temp);
return is;
}
我遇到的問題是,當我運行它時,它給了我額外的輸出。例如:當我輸入「34」時作爲輸入,所得到的bigint將是「3411」。誰能告訴我我做錯了什麼?
[SSCCE](http://sscce.org)會有所幫助。 – chris