fork download
  1. #include <iostream>
  2. #include <memory>
  3. using namespace std;
  4.  
  5. struct S {
  6. S(int X = 0, int Y = 0):x(X), y(Y){}
  7. int x;
  8. int y;
  9. };
  10.  
  11. int main() {
  12.  
  13. std::unique_ptr<S> ptr(new S(1, 4));
  14. S p = *ptr; // Copy the pointer's value
  15. std::cout << "x = " << p.x << "; y = " << p.y << endl;
  16. return 0;
  17. }
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
x = 1; y = 4