Name:
Anonymous
2010-08-24 8:59
#include <iostream>
using std::cout;
using std::endl;
class Integer
{
public:
Integer( int i ) : i_( i ) {}
operator int() { return i_; }
protected:
int i_;
};
class Fibonacci : public Integer
{
public:
Fibonacci( int i );
};
Fibonacci::Fibonacci( int i ) : Integer( i )
{
try {
if ( i == 0 || i == 1 ) {
throw Integer( i );
} else {
throw Integer( Fibonacci( i - 1 ) + Fibonacci( i - 2 ) );
}
} catch ( Integer ex ) {
i_ = ex;
}
}
int main()
{
const int UNTIL = 20;
for ( int loop = 0; loop < UNTIL; ++loop ) {
Fibonacci fibo( loop );
cout << fibo << ' ';
}
cout << endl;
return 0;
}
Name:
Anonymous
2011-02-19 20:42
>>18
A strange dialect of C that tries to implement some of Java's concepts.
The author is the very OP, it seems.