+ 2
can i send a string as parameter?
yesterday i try to send a string to a function in c++. But i dont know how can i send that. if anyone can ,try it. send a string as "sujith" and change it to "john" in a function
5 Antworten
+ 11
void change(std::string& str) {
str = "john";
}
int main() {
std::string test = "Sujith";
change(test);
}
+ 12
By reference or value?
+ 3
by reference may be good
+ 2
in any way
0
thank you for your best answer. can we change the program into return a string?