MIS 24053 Lecture Notes - Lecture 13: Stochastic Process
Document Summary
Number = number + 1; cout << "the parameter number: " To have a function with multiple outputs, we have to use pass by reference. We use & to denote a parameter that is passed by reference: Examples: void increment(int& number); void sumave (double, double,double&, double&); The address (reference) of that variable is passed to the function, instead of its value. If the function changes the parameter value, the change will be reflected in the corresponding argument, since they share the same memory location. To show how the function affects a variable which is used as an argument: #include using namespace std; void increment(int& number){ << number << endl; int main(){ return 0; } It is possible to use both pass by reference and pass by value parameters in the same function. // print the sum and average of two numbers. #include using namespace std; void sumave (double, double, double&, double&);