fork download
  1. #include <memory>
  2. #include <iostream>
  3. #include <string>
  4. using namespace std;
  5.  
  6. struct Node {
  7. shared_ptr<Node> next; string value;
  8. ~Node() { cout << "destroyed object with value " << value << endl; }};int main(){ shared_ptr<Node> a = make_shared<Node>(); shared_ptr<Node> b = make_shared<Node>(); shared_ptr<Node> c = make_shared<Node>(); a->value = "a"; b->value = "b"; c->value = "c"; a->next = b; b->next = c; c->next = a; cout << "Done!\n";}
Success #stdin #stdout 0.01s 5272KB
stdin
Standard input is empty
stdout
Done!