// Code derived from Stroustrup's PPP2 book// § 8.5.5 Pass-by-reference// -and beginning on p 281#include<iostream>usingnamespacestd;voidswap(double&d1,double&d2){doubletemp=d1;// copy d1's value to tempd1=d2;// copy d2's value to d2d2=temp;// copy d1's old value to d2}intmain(){doublex=1;doubley=2;cout<<"x == "<<x<<", y == "<<y<<'\n';// print: x == 1, y == 2swap(x,y);cout<<"x == "<<x<<", y == "<<y<<'\n';// print: x == 2, y == 1}