call by reference c++ example

C++
//call by reference example c++
#include <iostream>

using namespace std;

void swap(int& x, int& y) {
	cout << x << " " << y << endl;
	int temp = x;
	x = y;
	y = temp;
	cout << x << " " << y << endl;

}

int main() {
    
	int a = 7;
	int b = 9;

	swap(a, b);

}

Source

Also in C++: