Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- std::cout << str_manip("string to manipulate");
- std::string str;
- str_manip(str);
- std::cout << str;
- #include <string>
- // copying
- std::string str_manip(std::string str)
- {
- // manipulate str
- return str;
- }
- // in-place
- void str_manip(std::string& str)
- {
- // manipulate str
- }
- error: call of overloaded 'str_manip(std::__cxx11::string&)' is ambiguous
- std::string str;
- str_manip(str);
- std::cout << str;
- #include <string>
- // copying
- std::string str_manip(const std::string& str)
- {
- std::string dup = str;
- // manipulate dup
- return dup;
- }
- // in-place
- void str_manip(std::string& str)
- {
- // manipulate str
- }
Add Comment
Please, Sign In to add comment