FIBONACCI SERIES USING INCREMENT OPERATOR OVERLOADING

/*PROGRAM TO PRINT FIBONACCI SERIES USING INCREMENT OPERATOR OVERLOADING*/

#include<conio.h>

#include<iostream.h>

class fib_ovrld

{

int a,b,c;

public:

fib_ovrld()

{

a=-1;

b=1;

c=a+b;

}

void display()

{

cout<<c<<”    “;

}

void operator++()

{

a=b;

b=c;

c=a+b;

}

};

void main()

{

int n,i;

fib_ovrld f1;

clrscr();

cout<<“Enter the limit of the series: “;

cin>>n;

for(i=0;i<n;i++)

{

f1.display();

++f1;

}

getch();

}

Leave a Reply

Your email address will not be published. Required fields are marked *