#include #include "testreference.h" using namespace std; int main() { int number{9}; int number2{5}; cout << " " << endl; cout << "Variable \"number\" is: " << number << endl; cout << "The function call squareVal(number) gives: " << squareVal(number) << endl; cout << "But \"number\" is still: " << number << endl << endl; cout << "Now run squareRef(number) - it gives no output" << endl; squareRef(number); cout << "However, now variable \"number\" is now: " << number << endl << endl; cout << "A function passing by reference can still have an output. For example:" << endl; cout << "Variable \"number2\" is: " << number2 << endl; cout << "squareRef2(number2) gives the following output: " << squareRef2(number2) << endl; cout << "But beware: variable \"number2\" is now " << number2 << endl << " " << endl; } void squareRef(int & num) { num *=num; } int squareVal(int num) { return num*num; } int squareRef2(int & num) { num *=num; return 1234567; }