fork(5) download
  1. #include <iostream>
  2. #include <memory>
  3.  
  4. using namespace std;
  5.  
  6. struct Foo
  7. {
  8. Foo(std::string v) : value(v) {}
  9. void Bar() { std::cout << "Hello, " << value << "!" << std::endl; }
  10. std::string value;
  11. };
  12.  
  13. int main() {
  14.  
  15. std::unique_ptr<Foo> FooPtr = std::make_unique<Foo>("World");
  16. FooPtr->Bar();
  17. FooPtr.get()->Bar();
  18. (*FooPtr).Bar();
  19.  
  20. return 0;
  21. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
Hello, World!
Hello, World!
Hello, World!