diff --git a/excep.cpp b/excep.cpp new file mode 100644 index 0000000..bf541a0 --- /dev/null +++ b/excep.cpp @@ -0,0 +1,84 @@ +#include +#include +#include +#include + +using namespace std; + +class MyException{}; +class Dummy +{ + public: + Dummy(string s) : MyName(s) { PrintMsg("Created Dummy:"); } + Dummy(const Dummy& other) : MyName(other.MyName){ PrintMsg("Copy created Dummy:"); } + ~Dummy(){ PrintMsg("Destroyed Dummy:"); } + void PrintMsg(string s) { cout << s << MyName << endl; } + string MyName; + int level; +}; + + +void C(Dummy d, int i) +{ + cout << "Entering FunctionC" << endl; + d.MyName = " C"; + throw MyException(); + + cout << "Exiting FunctionC" << endl; +} + +void B(Dummy d, int i) +{ + cout << "Entering FunctionB" << endl; + d.MyName = "B"; + C(d, i + 1); + cout << "Exiting FunctionB" << endl; +} + +void A(Dummy d, int i) +{ + cout << "Entering FunctionA" << endl; + d.MyName = " A" ; + //Dummy* pd = new Dummy("new Dummy"); //Not exception safe!!! + tr1::shared_ptr sp(new Dummy("new Dummy")); + B(d, i + 1); + //delete pd; + cout << "Exiting FunctionA" << endl; +} + + +int main() +{ + cout << "Entering main" << endl; + try + { + Dummy d(" M"); + A(d,1); + } + catch (MyException& e) + { + cout << "Caught an exception of type: " << typeid(e).name() << endl; + } + + cout << "Exiting main." << endl; + char c; + cin >> c; +} + +/* Output: + Entering main + Created Dummy: M + Copy created Dummy: M + Entering FunctionA + Copy created Dummy: A + Entering FunctionB + Copy created Dummy: B + Entering FunctionC + Destroyed Dummy: C + Destroyed Dummy: B + Destroyed Dummy: A + Destroyed Dummy: M + Caught an exception of type: class MyException + Exiting main. + +*/ diff --git a/mesos_note/watch.list b/mesos_note/watch.list new file mode 100644 index 0000000..6217e96 --- /dev/null +++ b/mesos_note/watch.list @@ -0,0 +1 @@ +https://issues.apache.org/jira/browse/MESOS-2145