#include #include using namespace std; #include jmp_buf jumper; // declare a jump buffer to save program state class Fraction { int numer, denom; public: Fraction(int n = 0, int d = 1) : numer(n), denom(d) { cout << "Fraction " << this << " created" << endl; if (d == 0) longjmp(jumper,1); // make sure denom is not 0 } ~Fraction() { cout << "~Fraction " << this << " destroyed" << endl; } friend ostream& operator<<(ostream& o, const Fraction& f) { return (o << f.numer << '/' << f.denom); } }; int main() { int i1, i2; int state; state = setjmp(jumper); if (state != 0) cout << "** Go back in time with state " << state << endl; cout << "Enter two ints => "; cin >> i1 >> i2; Fraction f(i1,i2); cout << f << endl; cout << "*** End of Program ***\n"; }