fork download
  1. #include <string>
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. void func1(string s) {
  6. s += '1';
  7. }
  8.  
  9. void func2(string &s) {
  10. s += '2';
  11. }
  12.  
  13. int main ()
  14. {
  15. string str = "----";
  16. func1(str);
  17. func2(str);
  18.  
  19. cout << str << endl;
  20.  
  21. return 0;
  22. }
  23.  
Success #stdin #stdout 0s 2984KB
stdin
Standard input is empty
stdout
----2