cant pass a member of a class by reference...

I have this 2 functions

myfunction1 (myclass &value)
myfunction2 (int &value)

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)
?????

Any help ? Thanks
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.
tonnot wrote:
But how can I call myfunction2 ???

Have you tried the options you list here? Did they work?

EDIT: I totally agree with the post above.
Last edited on
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.

Thanks
Can you show us the actual method your talking about?
Topic archived. No new replies allowed.