Whats the difference between passing a struct by reference/not?
struct editStruct (struct x)
struct editStruct (struct &x)
What are the differences in passing these two?
Whats the difference between passing a struct by reference/not?
struct editStruct (struct x)
struct editStruct (struct &x)
What are the differences in passing these two?
as far as I know, passing something by reference passes a pointer so that any changes made in the function are actually made to the variable, whereas without the & means that any changes are lost unless the variable is returned at the end and saved.
I assume that it is the same with structs...
Weirdly, finding a tutorial to explain references seems hard... the word "reference" is just too overloaded.
Anyway, what do you know of references? What about say, passing an int by reference?
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Declare a really big struct.
Call a function lots of times.
Compare.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
wont one edit the value(&) and permanenlty change it wherease the other jsut copies and uses the value. im thinking the same as passing to functions here
Ok the people saying passing by reference lets you change the actual value, whereas not makes a copy are correct I believe.
[edit3] - Found the answer to my second Q, thanks though CornedBee.
Last edited by Sparrowhawk; 02-23-2009 at 04:03 PM.
Create a new thread for a new topic, please.
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law