#include template T PassByValue(T a, T b, T c) { a = a - 1; b = b - 1; c = c - 1; return a*b*c; } template T PassByReference(T& a, T& b, T& c) { a = a - 1; b = b - 1; c = c - 1; return a*b*c; } template T PassByConstReference(const T& a, const T& b, const T& c) { a = a - 1; b = b - 1; c = c - 1; // [C++Error] Project2.cpp(21): // Cannot modify a const object. return a*b*c; } int main() { int x = 3, y = 4, z = 5; cout << "This program compares 3 types of parameter passing " << endl; cout << "note the values of actual parameters, x, y, and z, " << endl; cout << "before and after function call " << endl; cout << endl; cout << "$$pass by value$$ " << endl; cout << "before function call, x, y, z = "; cout << x << " " << y << " " << z << endl; cout << "function return value = "; cout << PassByValue(x, y, z) << endl; cout << "after function call, x, y, z = "; cout << x << " " << y << " " << z << endl; cout << endl; cout << "$$pass by reference$$ " << endl; cout << "before function call, x, y, z = "; cout << x << " " << y << " " << z << endl; cout << "function return value = "; cout << PassByReference(x, y, z) << endl; cout << "after function call, x, y, z = "; cout << x << " " << y << " " << z << endl; cout << endl; cout << "PLEASE INCLUDE last part of code and RUN AGAIN " << endl; // cout << endl; // cout << "$$pass by const reference$$ " << endl; // cout << "before function call, x, y, z = "; // cout << x << " " << y << " " << z << endl; // cout << "function return value = "; // cout << PassByConstReference(x, y, z) << endl; // cout << "after function call, x, y, z = "; // cout << x << " " << y << " " << z << endl; getchar(); // delete if using MS Visual C++ return 0; }