fork download
  1. #include <string>
  2.  
  3. struct Foo
  4. {
  5. const std::string* ptr;
  6. void setPtr(const std::string& text)
  7. {
  8. ptr = &text;
  9. }
  10. };
  11.  
  12. int main()
  13. {
  14. std::string s("hello");
  15. Foo f;
  16. f.setPtr(s);
  17. }
  18.  
Success #stdin #stdout 0.01s 2808KB
stdin
Standard input is empty
stdout
Standard output is empty