Edited: I need to change the values of several variables as they run several times thorugh a timer. I need to keep updating the values with every iteration through the timer
To solve the problem above, different languages make different decisions.
for Java, the solution is as what we see in this article.
for C#, the solution is allow side-effects and capture by reference is the only option.
for C++11, the solution is to allow the programmer make the decision. They can choose to capture by value or by reference. If capturing by value, no side-effects would occur because the variable referenced is actually different. If capture by reference, side-effects may occur but the programmer should realize it.