string passed by reference c++ code example
Example: how to pass a string by reference in c++
#include <iostream>
using namespace std;
void func (string &s)
{
s+="d";
}
int main()
{
string a="abc";
func(a);
cout << a << endl;
return 0;
}
// output will be abcd