fork download
  1. #include <iostream>
  2. #include <memory>
  3.  
  4. using namespace std;
  5.  
  6. struct MyStruct {
  7. private: string _name;
  8.  
  9. public: MyStruct(string &aName): _name(aName) {}
  10.  
  11. public: string name() {
  12. return this->_name;
  13. }
  14. };
  15.  
  16. int main() {
  17. string s = {"test"};
  18. auto_ptr<MyStruct> a(new MyStruct(s));
  19. auto_ptr<MyStruct> p = a;
  20.  
  21. cout << "p: " << p->name() << endl;
  22. cout << "a: ";
  23. cout << a->name() << endl;
  24.  
  25. return 0;
  26. }
Runtime error #stdin #stdout 0s 16056KB
stdin
Standard input is empty
stdout
p: test