#include <iostream>
using namespace std;
class fibo
{
private:
unsigned long int n1,n2,final;
public:
//use constructor initializer list
fibo(): n1(0), n2(1), final(n1+n2)
{
//n1 = 0;
//n2 = 1;
//final = n1 + n2;
}
fibo(int x1,int x2) //Parameterised Constructor
{
n1 = x1;
n2 = x2;
for (int x = 0;x<=8; x++)
{
final = n1 + n2;
cout << final << " ";
n1 = n2;
n2 = final;
}
}
void calc()
{
for (int x = 0;x<=8; x++)
{
final = n1 + n2;
cout << final << " ";
n1 = n2;
n2 = final;
}
//no need to return
//return 0;
}
fibo(fibo &i); // Copy Constructor
};
fibo::fibo(fibo &i)
{
n1= i.n1;
n2 = i.n2;
final = i.final;
}
int main()
{
cout << "0 1 " ;
fibo f1(0,1);
//no need to create new object
//fibo f2 = f1;
//call f1.calc() instead of f2.calc()
f1.calc();
return 0;
}