Guest User

Untitled

a guest
Nov 13th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. std::cout << str_manip("string to manipulate");
  2.  
  3. std::string str;
  4. str_manip(str);
  5. std::cout << str;
  6.  
  7. #include <string>
  8.  
  9. // copying
  10. std::string str_manip(std::string str)
  11. {
  12. // manipulate str
  13. return str;
  14. }
  15.  
  16. // in-place
  17. void str_manip(std::string& str)
  18. {
  19. // manipulate str
  20. }
  21.  
  22. error: call of overloaded 'str_manip(std::__cxx11::string&)' is ambiguous
  23.  
  24. std::string str;
  25. str_manip(str);
  26. std::cout << str;
  27.  
  28. #include <string>
  29.  
  30. // copying
  31. std::string str_manip(const std::string& str)
  32. {
  33. std::string dup = str;
  34. // manipulate dup
  35. return dup;
  36. }
  37.  
  38. // in-place
  39. void str_manip(std::string& str)
  40. {
  41. // manipulate str
  42. }
Add Comment
Please, Sign In to add comment