You might be refering to
this thread where you would parse by reference instead of making copies like your swap function does.
Which would alter your code to be:
Code:
#include <iostream>
#include <string>
namespace stacy
{
//swap() swaps string1 and string2, then prints the new values.
void swap(std::string &string1, std::string &string2)
{
std::string holder;
holder = string1;
string1 = string2;
string2 = holder;
std::cout << "String 1 is now '" << string1
<< "' and string 2 is '" << string2 << "'."
<< std::endl;
}
}
int main()
{
std::string one = "one";
std::string two = "two";
std::cout << "Befor swap: " << one << " " << two << std::endl;
stacy::swap(one, two);
std::cout << "After swap: " << one << " " << two << std::endl;
std::cin.get();
}