[Solved] C++ functions, pass by reference


I’m not going to answer with a complete solution (and you are free to improve your question so you get better answers later), but regarding the question title, here are some hints.

Your declaration

char displaymenu(int num1, int num2);

and your definition

char displaymenu(int &num1 = num1, int &num2 = num2)

should have the same signature. In order to pass references, change the declaration to

char displaymenu(int &num1, int &num2);

Also, since you transfer values by reference, you should get rid of the global variables int num1, num2 = 0; below the using namespace std;. They are not needed anymore. Then, fix the displaymenu function definition by removing the (not working) standard values assignment. After that, at least the compiler should accept your code, just it won’t really work for some cases when you execute it.

0

solved C++ functions, pass by reference