fork(2) download
  1. #include <iostream>
  2. #include <memory>
  3. using namespace std;
  4.  
  5. struct A {
  6. weak_ptr<A> Next;
  7. ~A(){ cout << "deleted" << endl; }
  8. };
  9.  
  10. void Foo()
  11. {
  12. auto a1 = make_shared<A>();
  13. auto a2 = make_shared<A>();
  14. a1->Next = a2;
  15. a2->Next = a1;
  16. }
  17.  
  18. int main() {
  19. Foo();
  20. // your code goes here
  21. return 0;
  22. }
Success #stdin #stdout 0s 4276KB
stdin
Standard input is empty
stdout
deleted
deleted