MIS 24053 Lecture Notes - Lecture 13: Stochastic Process

13 views4 pages

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&);

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents