ITP 165x Lecture Notes - Lecture 11: Function Overloading

33 views1 pages

Document Summary

Itip 165: intro to c++ - lecture 11: more functions, passing by reference. The desk is empty right before the program starts. When a function starts, its paper gets put on top of the paper stack. The current function is the paper on top of the stack. When a function ends, its paper is removed, and the program continues on the paper below it. If there are no papers left on the desk, the program is over. If you want to swap values, you must pass by reference. If we pass a parameter by reference, modifications to the parameter will persist. To pass a parameter by reference, in the function declaration add a & between the type and variable name. When calling a function with pass-by-reference parameters, the parameters must be variables. If you pass in a literal number (e. g. 10), c++ will recognize it as a constant. When passing by reference, no copy is made, saves memory.

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