fork download
  1. #include <iostream>
  2. #include <memory>
  3. using namespace std;
  4.  
  5. void func() {
  6. shared_ptr<int> p2 = make_shared<int>(20);
  7. shared_ptr<int> p3 = p2;
  8. cout << "*p2=" << *p2 << endl;
  9. p2.reset();
  10. cout << "*p3=" << *p3 << endl;
  11. p3.reset();
  12.  
  13. unique_ptr<int> p6 = make_unique<int>(10);
  14. cout << "*p6=" << *p6 << endl;
  15. p6.get_deleter();
  16. }
  17.  
  18. int main() {
  19. func();
  20. cout << "Bye" << endl;
  21. }
Success #stdin #stdout 0.01s 5276KB
stdin
Standard input is empty
stdout
*p2=20
*p3=20
*p6=10
Bye