Fibonacci numbers

This is a discussion on Fibonacci numbers within the C++ Programming forums, part of the General Programming Boards category; Here it is if you've ever wanted to have a class that creates them, and we all do, I just ...

Fibonacci numbers

Here it is if you've ever wanted to have a class that creates them, and we all do, I just know it :-) This is a quick class I wrote while being bored, if anyone wants to make comments I'd welcome them. :-)

Minor bug...delete cache should be delete [] cache...but yeah, you were right, I've always wanted the code for that one.

One more comment, too. IMO you needn't bounds check on the array access's because of the speed tradeoff of the two comparisons. Most code will/should mind it's own bounds...and if it does then not only does your code do bounds checking, so does their's! :-/

>>IMO you needn't bounds check on the array access's because of the speed tradeoff of the two comparisons.
I like to be neighborly and protect people against themselves when I can :-) But a middle ground is probably better, give the user a choice of a range checked get() for more compact code, or non checked get() for speedyness, like the [] and at() methods of vector.