Skip to content

Instantly share code, notes, and snippets.

@a-square
Created February 5, 2017 19:58
Show Gist options
  • Save a-square/8637b5d1459d1ef95f60a35cbbfcfd15 to your computer and use it in GitHub Desktop.
Save a-square/8637b5d1459d1ef95f60a35cbbfcfd15 to your computer and use it in GitHub Desktop.
#include <iostream>
class Foo {
public:
explicit Foo(int) {
throw "Wow!";
}
};
class Bar {
public:
Bar() try : foo(4) {
std::cout << "Much exceptions" << std::endl;
} catch(...) {
std::cout << "Such semantics" << std::endl;
}
private:
Foo foo;
};
int main() {
try {
Bar bar;
} catch(...) {
std::cout << "So C++" << std::endl;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment