【发布时间】:2013-10-02 00:34:51
【问题描述】:
这是我的 operator>> 重载代码。它应该将数字带到分号并将它们放入 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 会有所帮助。
标签: c++ operator-overloading bigint