fork(9) download
  1. #include <string>
  2. using std::string;
  3.  
  4. #include <iostream>
  5. using std::cout; using std::endl;
  6.  
  7. int main()
  8. {
  9. string s1 = string("s1");
  10. const string& s2 = string("s2");
  11. string& s3 = string("s3");
  12.  
  13. cout
  14. << s1 << ", "
  15. << s2 << ", "
  16. << s3 << endl;
  17. return 0;
  18. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:11:29: error: invalid initialization of non-const reference of type ‘std::string& {aka std::basic_string<char>&}’ from an rvalue of type ‘std::string {aka std::basic_string<char>}’
stdout
Standard output is empty