Normally, I use pass by reference in following situations:
1) The objetc is bigger size than a pointer: In this case, if I dont want not modify the objetc, use a const reference:
Reference object;
foo(object);
with foo declared as:
void foo(const Reference & object);
2) For code clarify, trying to avoid thigs like this:
int f1 = xxx;
int f2 = yyy;
int f3 = zzz;
....
foo(f1, f2, ............)
using an struct:
struct X
{
int f1;
int f2;
int f3;
....
};
X x;
x.f1 = xxx;
.....
foo(X);
with foo defined as:
foo(const X & x);
3) for speedup pourposes: Remember that calling functions must put parameters on stack
4) You need to modify parameters inside the function.
Reference object;
foo(object);
with foo declared as:
void foo(Reference & object);