codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
#include <iostream> using namespace std; class A { public: A() { cout << "A's Ctor" << endl; } A(const A&) { cout << "A's Copy Ctor" << endl; } ~A() { cout << "A's Dtor" << endl; } const char *what() const { return "Exception in A"; } }; class B { public: B() { cout << "Bs ctor" << endl; } ~B() { cout << "B dtor" << endl; } }; void MyFunc() { B b; throw A(); } int main() { try { MyFunc(); } catch (A a) { cout << a.what() << endl; } catch (char *str) { cout << "Caught some other ex " << str << endl; } }
Private
[
?
]
Run code
Submit