fork download
  1. #include <iostream>
  2.  
  3. struct A {
  4. A() { throw "cake"; }
  5. };
  6.  
  7. struct B : A {
  8. B() try : A() {
  9. // initialize B some more
  10. } catch(char const* reason) {
  11. ::std::cout << "Could not initialize B: " << reason << "\n";
  12. throw;
  13. }
  14. };
  15.  
  16. int main() {
  17. B b;
  18. }
Runtime error #stdin #stdout #stderr 0s 3460KB
stdin
Standard input is empty
stdout
Could not initialize B: cake
stderr
terminate called after throwing an instance of 'char const*'