/* ex_2_5.c++ */ #include using namespace std; void fonction_val (int param) { cout << "fonction_val> "; cout << "param : " << ¶m << ":" << param << endl; param=3; } void fonction_ref (int& param) { cout << "fonction_ref> "; cout << "param : " << ¶m << ":" << param << endl; param=4; } void fonction_ptr (int * param) { cout << "fonction_ptr> "; cout << "param : " << ¶m << " : " << param << endl; cout << "fonction_ptr> "; cout << "*param : " << param << " : " << *param << endl; *param=5; } int& get_max_ref (int& param1, int& param2) { return ((param1>param2) ? param1 : param2); } int main() { int a=1, b=1; cout << "main 1 > "; cout << "a : " << &a << " : " << a << endl; cout << "main 1 > "; cout << "b : " << &b << " : " << b << endl; int& c = b; c=2; cout << "main 2 > "; cout << "c : " << &c << " : " << c << endl; cout << "main 2 > "; cout << "a=" << a << ", b=" << b << ", c=" << c << endl; fonction_val (b); cout << "main 3 > "; cout << "a=" << a << ", b=" << b << endl; fonction_ref (b); cout << "main 4 > "; cout << "a=" << a << ", b=" << b << endl; fonction_ptr (&b); cout << "main 5 > "; cout << "a=" << a << ", b=" << b << endl; int& d = get_max_ref(a, b); d = 6; cout << "main 6 > "; cout << "a=" << a << ", b=" << b << endl; get_max_ref(a, b) = 7; cout << "main 7 > "; cout << "a=" << a << ", b=" << b << endl; }