Sorry I mistakenly added "return 0". Taking out this line, other things compiles (I tested). My main question is about the way of transfer variables. If result is a vector, I should use reference for calling. case1 and case2 both work. I am not clear about the difference between these 2. And which one is better?