Can someone answer my question?8

Pages: 12
closed account (LN3RX9L8)
In a pass by reference function, if I keep calling it inside a while loop and want a value returned do I have to say return variable for everything I want returned ?
closed account (LN3RX9L8)
and is it okay to have something like this where the only pass by reference value i want is the last one

int turn_plays(int array [], int boats, int &counts);

is this function prototype correct or can't be done in c++?

It works in Xcode but I am not sure if it is right

Thanks
In a pass by reference function, if I keep calling it inside a while loop and want a value returned do I have to say return variable for everything I want returned ?


I don't understand what you are trying to say here. Please give an example.

is this function prototype correct or can't be done in c++?


Works fine. References are not special.
Variable is a name for a memory location. When a function introduces a variable, it reserves memory. If it then passes a reference to another function, the called function will modify the memory location of the calling function.

If you call a function several times, in loop for example, each call in turn has the chance to do something.
Topic archived. No new replies allowed.
Pages: 12