fork(2) download
  1. #include <iostream>
  2. #include <memory>
  3.  
  4. class A
  5. {
  6. public:
  7.  
  8. A() : p(std::make_shared<int>()) {}
  9.  
  10. int value() const { return *p; }
  11. void set_value(int value) { *p = value; }
  12.  
  13. private:
  14. std::shared_ptr<int> p;
  15. };
  16.  
  17. int main()
  18. {
  19. A a(a);
  20. a.set_value(42); // Oops!!!!!!!!
  21. std::cout << a.value() << std::endl;
  22. }
Runtime error #stdin #stdout 0s 15232KB
stdin
Standard input is empty
stdout
Standard output is empty