// example parameter passing: strings // Mikhail Nesterenko // 10/11/99 #include #include using std::cout; using std::endl; using std::string; void example1(string); //tries to modify string void example2(string&); //tries to modify string (with more success) // demos string parameter passing int main(){ string noname="Doe"; example1(noname); cout << noname << endl; example2(noname); cout << noname << endl; } // modifies string, why doesn't it work? void example1(string s) { s = "John " + s; } // modifies string, does it work? void example2(string& s) { s = "Jane " + s; }