-1
第二次不起作用。我试图filestr.clear()/ flush()和其他人没有结果。如果我在第一时间评论一切正常,但我需要对象的数量。有人请帮助getline不能用于第二个呼叫
while (std::getline(filestr, line)) {
if (line.find("<rect") != std::string::npos) count_rect++;
}
rect = new Rectangle[count_rect];
while (std::getline(filestr, line1)) {
//code
}
代码格式不正确。你似乎认为2nd while循环是*嵌套*,但实际上它是在* first循环之后运行的。 – zett42