You cannot change the value of your argument (arr) if it's not passed in by reference (&). In general, you would want to return the pointer, so your method should be:
arr=foo();
It's bad juju to try to reassign arguments; I don't recommend the (&) solution.