fork download
  1. #include <iostream>
  2.  
  3. class Except
  4. {
  5. Except(const Except& other) { std::cout << "Copy\n"; i = other.i; }
  6. public:
  7. int i;
  8. Except() : i(1) {}
  9. };
  10.  
  11. int main()
  12. {
  13. try
  14. {
  15. Except ex1;
  16. ex1.i = 19;
  17. throw ex1;
  18. }
  19. catch (Except& ex2)
  20. {
  21. std::cout << ex2.i << "\n";
  22. }
  23. return 0;
  24. }
  25.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:5: error: ‘Except::Except(const Except&)’ is private
prog.cpp:17: error: within this context
stdout
Standard output is empty