退了的房又想要了咋整 (转载)# Joke - 肚皮舞运动
n*e
1 楼
class Iterator {
public:
Iterator() : cur(0) {};
bool hasNext() {
return cur < 20;
};
int next() {
++cur;
return cur;
};
private:
int cur;
};
int main() {
Iterator it;
int a = it.next();
int b = it.next();
cout << a << " " << b << endl;
cout << it.next() << " " << it.next() << endl;
}
为啥输出是
1 2
4 3
而不是
1 2
3 4
public:
Iterator() : cur(0) {};
bool hasNext() {
return cur < 20;
};
int next() {
++cur;
return cur;
};
private:
int cur;
};
int main() {
Iterator it;
int a = it.next();
int b = it.next();
cout << a << " " << b << endl;
cout << it.next() << " " << it.next() << endl;
}
为啥输出是
1 2
4 3
而不是
1 2
3 4