fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. struct S {
  5. S(const std::string &s) : str(s){}
  6. const std::string &get() const {return str;}
  7. std::string str;
  8. };
  9.  
  10. int main() {
  11. S *s1 = new S("abc");
  12. S *s2 = new S("def");
  13. S *s3 = new S("ghi");
  14.  
  15. std::cout << s1->get() << '\n' << s2->get() << '\n' << s3->get();
  16. }
Success #stdin #stdout 0.02s 2812KB
stdin
Standard input is empty
stdout
abc
def
ghi