#include using namespace std; int main() { void swap(int& x, int& y); // void swap(int &x, int &y); also works int a = 1, b = 2; cout << "a = " << a << " b = " << b << endl; swap(a,b); cout << "a = " << a << " b = " << b << endl; return 0; } void swap(int&x, int& y) { int temp; temp = x; x = y; y = temp; }