I want to pass the values by ref to avoid copies.
Ok, I have a object created like this
a_struc * my_struc= new a_struc;
(a_struc is a simple struct with 3 fields, the third is an int field called a3. )
myfunction1(*mystruc) works
But how can I call myfunction2 ??? :
myfunction2(mystruc->a3)
myfunction2(*mystruc->a3)
?????
myfunction2(mystruc->a3); is correct, but there is no reason to pass primitive types by reference. Passing them by value is not only just as fast, but can actually be faster because it avoids the overhead of setting up a reference.
I have written the example with the int, but the real situation is that I have a member with some bytes (more than 4 )
I'm unable to write the code, sometimes the compiler dont let me and other I have a memory error ....
myfunction2(mystruc->a3); compiles but inside myfunction2 I have :
int si = sizeof value; this line that gives me error.