#include <cstdio>
struct B{
int n,a=1,b=1;
B(int n):n(n){
printf("+(%d)[%08p]\n",n,this);
}
B(B& n){
*this=n;
printf("B(B) [%08p] [%08p]\n",this,&n);
}
~B(){
printf("-[%08p]\n",this);
}
void next(){
n-=1;
int r=a+b;
b=a;
a=r;
}
B& begin(){
return *this;
}
int operator*() {
return b;
}
B& operator++(){
next();
return *this;
}
bool operator!=(int b) {
return n>b;
}
int end(){
return 0;
}
};
int main()
{
for (auto x:B(10))
printf("%-3d",x);
printf("\n===\n");
auto r=B(10);
printf("=\n");
auto a=r.begin(); //Зачем тут ещё один конструктор B(B) вызывается?
printf("=\n");
auto b=r.end();
for (;a!=b;++a)
printf("%-3d",*a);
}