John said:
It's fine, why shouldn't it be? Do you think it contradicts something that
Richard or myself have already said? If so what? The rule about not being
able to reseat a reference when it has been initialised still applies.
Confused.
john
Thanks.
Each time the for loop in function1 is executed, a new v2 is declared
and refers to v1, right?[/QUOTE]
Right, except I would say created not declared, v2 is declared once only.
Each different time that v2 is created it can refer to a different object,
but within the same creation it always refers to the same object.
By the way, in function2, is the line-- v2.clear(), necessary?
If your function depends on the fact that v2 must refer to an empty vector
then it's good practice to empty it at the start of function rather then
relying on the caller of the function to always call with an empty vector.
On the other hand if all you are going to do is assign a whole new vector to
v2 (which is what your comments suggest) then it isn't necessary.
john