You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
3.Create two functions, one that takes a string* and one that takes a string&. Each of these functions should modify the outside string object in its own unique way. In main(), create and initialize a string object, print it, then pass it to each of the two functions, printing the results.
*/
#include<string>
#include<algorithm>
#include<iostream>
voidreverse(std::string &string){
std::reverse(string.begin(), string.end());
}
voidreverse2(std::string *string){
std::reverse(string->begin(), string->end());
}
intmain(int argc, charconst *argv[])
{
std::string string ("3.Create two functions, one that takes a string* and one that takes a string&. Each of these functions should modify the outside string object in its own unique way. In main(), create and initialize a string object, print it, then pass it to each of the two functions, printing the results.");
reverse(string);
std::cout << "\nreverse function 1,take reference.\n\n" << std::endl;
std::cout << string << std::endl;
reverse2(&string);
std::cout << "\nreverse function 2,take pointer.\n\n" << std::endl;