Summary
Full Transcript
►Full C++ Series Playlist: https://www.youtube.com/playlist?list=PLvv0ScY6vfd8j-tlhYVPYgiIyXduu6m-L ►Find full courses on: https://courses.mshah.io/ ►Join as Member to Support the channel: https://www.youtube.com/channel/UCA64pZbN5Mz5NxC3SO4qpDg/join ►Lesson Description: In this lesson we take a look at 'pass by reference' semantics which allows us to mutate (i.e. change the value) of a variable, as well as more efficiently pass data around. Pass by reference behind the scenes is using something called a 'pointer', which we will learn about later. Pass by reference tends to be one of the preferred ways to pass data around in functions when we need to share data in a function, as it is efficient, and generally more safe. Note: You'll observe we are spending more time in 'sys' (i.e. system time) in the video allocating memory for the copies. This becomes even worse if you have multiple programs running at once competing for system resources (i.e. memory allocation) Note 2: As noted, we tend to not pass by reference primitive variables (e.g. an int) as the performance could be slightly more to pass by reference (which is passing a pointer behind the scenes). ►YouTube Channel: https://www.youtube.com/c/MikeShah ►Please like and subscribe to help the channel!
