// Annother illustration of C++ reference parameters. // A rather strange example involving a function that returns a reference. #include #include int& f(bool b, int& i, int& j){ if (b) return i; else return j; } int main() { using namespace std; int a, b; a = b = 0; f(true, a, b) = 7; // assigning to a cout << "a: " << a << endl; // 7 cout << "b: " << b << endl; // 0 a = b = 0; f(false, a, b) = 7; // assigning to b cout << "a: " << a << endl; // 0 cout << "b: " << b << endl; // 7 }