#include <iostream>
#include <iterator>
class Fibonacci {
private:
int current;
int next;
public:
class iterator {
private:
int current;
int next;
public:
using iterator_category = std::input_iterator_tag;
using value_type = int;
using difference_type = std::ptrdiff_t;
using pointer = const int*;
using reference = const int&;
iterator(int current = 0, int next = 1) : current(current), next(next) {}
int operator*() const { return current; }
iterator& operator++() {
int temp = current;
current = next;
next = temp + next;
return *this;
}
iterator operator++(int) {
iterator temp = *this;
++(*this);
return temp;
}
bool operator==(const iterator& other) const { return current == other.current; }
bool operator!=(const iterator& other) const { return !(*this == other); }
};
Fibonacci() : current(0), next(1) {}
iterator begin() { return iterator(); }
iterator end() { return iterator(89); } // Arbitrary end point
};
int main() {
Fibonacci fib;
std::cout << "First 10 Fibonacci numbers: ";
int count = 0;
for (auto i : fib) {
if (count++ == 10) break;
std::cout << i << " ";
}
std::cout << std::endl;
return 0;
}