1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
#include <iostream.h>
class Object
{
public:
Object(char const *name);
~Object();
void fun();
void hello();
private:
char const
*name;
};
/*
Object::Object(char const *n)
{
name = n;
cout << "Object constructor of " << name << "\n";
}
Object::~Object()
{
cout << "Object destructor of " << name << "\n";
}
void Object::fun()
{
cout << "Object fun() of " << name << "\n";
throw new Object("'new object'");
}
void Object::hello()
{
cout << "Hello by " << name << "\n";
}
*/
void emptythrow(Object *o)
{
cout << "Caught exception\n";
o->hello();
throw;
}
/*
int main()
{
Object out{ "'main object'" };
try
{
try
{
out.fun();
}
catch (Object *o)
{
emptythrow(o);
}
}
catch (Object *o)
{
cout << "Caught exception again\n";
o->hello();
delete o;
}
}
*/
|