fork download
  1. #include <iostream>
  2. #include <memory>
  3. using namespace std;
  4.  
  5. void TestUP(unique_ptr<int> &temp)
  6. {
  7. cout<<*temp<<endl;
  8. *temp=100;
  9. }
  10.  
  11. int main (void)
  12. {
  13. int a{10};
  14. unique_ptr<int> p{&a};
  15. TestUP(p);
  16. cout<<a<<endl; //yes, it is 100 now
  17. p.release(); //you bind a local variable, don't forget to release
  18. return 0;
  19. }
Success #stdin #stdout 0s 3412KB
stdin
Standard input is empty
stdout
10
100