SJ @ 2008-12-14, 10:11 am wrote:
for example, when you write some recursion to a certain depth, like
void rec (int currentDepth, int maxDepth) {}
you'd want to pass maxDepth as a reference (or a global variable) and currentDepth by value. it really depends on what you are doing.
Definitely not glboal - unless it was a constant. If you passed it by reference in C or C++ you'd want to specify it as a constant too.
Passing by reference is only a good idea if you want to change the variable inside your function (which is not usually a good idea) or if you have some way of marking it as a constant so you can't change it even accidentally.