#include <string>using std::string; #include <iostream>using std::cout; using std::endl; int main(){ string s1 = string("s1"); const string& s2 = string("s2"); string& s3 = string("s3"); cout << s1 << ", " << s2 << ", " << s3 << endl; return 0;}
Standard input is empty
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>}’
Standard output is empty
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!