Can someone please tell me what reference parameters are? For example, what's the difference between "void subprogram(int n)" and "void subprogram(int &n)"? And what's the difference between pass-by-value and pass-by-reference?
when you do pass by value the compiler makes a copy of the passed variable of the subprogram, meaning all operation you do using that variable, are actually done on a copy of the original passed variable, the original value remains unchanged
when you do pass by reference you are passing an alias of the original value to the subprogram, that means all operations you do in the subprogram with the original variable as argument, are done on the actual original value
pass by value is "void subprogram(int n)" and pass by reference is "void subprogram(int &n)", the only difference is using "&" to indicate to the compiler that n is supposed to be a refference for the value passed to the subprogram.