fork(1) download
  1. #include <iostream>
  2. #include <memory>
  3. using namespace std;
  4.  
  5. struct node
  6. {
  7. int value;
  8. unique_ptr<node> left;
  9. unique_ptr<node> right;
  10. node() : value(0), left(nullptr), right(nullptr) {}
  11. node(int v) : value(v), left(nullptr), right(nullptr) {}
  12. };
  13.  
  14. int main() {
  15. node n;
  16. n.value = 200;
  17. n.left = unique_ptr<node>(new node(10));
  18. n.right = unique_ptr<node>(new node(20));
  19. cout << n.left.get() << "\n" << n.value << "\n" << n.right.get() << endl;
  20. return 0;
  21. }
Success #stdin #stdout 0s 3476KB
stdin
Standard input is empty
stdout
0x927fa10
200
0x927fa20