#ByValue vs ByRef params

9 messages · Page 1 of 1 (latest)

fleet urchinBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.

severe flume
#

;compile

int x = 5;
int y = 5;
printf("%d\n", x++);
printf("%d\n", x);
printf("%d\n", ++y);
printf("%d\n", y);
real badgerBOT
#
Program Output
5
6
6
6
severe flume
#

The value of x++ is what x was before
The value of ++x is what x is after

#

Both still increment

#

Also ya, passing structs by value makes a copy. If you want to modify the original, you need to pass a pointer to it

#

Best way I think of it: in Java, every object (non-primative) is passed by a pointer (sort of)

fleet urchinBOT
#

@pseudo kettle Has your question been resolved? If so, run !solved :)

fleet urchinBOT
#

Thank you and let us know if you have any more questions!

This thread is now set to auto-hide after an hour of inactivity