- 1 current stop: learning
- 2 upcoming
- 3 upcoming
- 4 upcoming
- 5 upcoming
Finish after stop 5
Stop 1 of 5 · Print shop counter
Trick to keep in mind+3 XP
No & means a photocopy: the function scribbles on its copy and you see nothing.
By default C++ passes each argument by value, so a function receives its own copy, even of a whole vector. Adding elements to that copy cannot reach the caller's vector, and copying a big container is slow too. A reference parameter makes the function work on the caller's own object. Remember that Java works differently for objects.
Read it once, then a question tests whether the trick stuck.