blob: 81661e305cf5ff9b144a6517430d9be5bcb26f1f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
#include <iostream>
class interval {
public:
int low, hi;
interval(int low, int hi);
void iterate(int& i);
int ok(int& i);
int next(int& i);
};
interval::interval(int low, int hi) {
this->low = low;
this->hi = hi;
}
void interval::iterate(int& i) { i = low; }
int interval::ok(int& i) { return i <= hi; }
int interval::next(int& i) { return i++; }
int main() {
interval s = interval(3, 10);
int i;
s.iterate(i);
while(s.ok(i))
std::cout << s.next(i) << "\n";
}
|