// compile with: g++ hello.cpp #include<iostream> #include<string> #include<vector> using namespace std; // function prototype, & means "pass by reference" - value will be copied back out // note: just typing & once is less typing, but also if you just look at main you // won't know if swap actually changes x and y void swap(int &a, int &b) { int temp = a; a = b; b = temp; } int main(int argc, char * argv[]) { cout << "x: "; int x; cin >> x; cout << "y: "; int y; cin >> y; cout << "swapping..." << endl; swap(x, y); cout << "x: " << x << endl; cout << "y: " << y << endl; return 0; }