pass by reference

I have to pass word in following expression in following way
int word = i;
trans.set_data_ptr((unsigned char*)(&word));

Now I have to pass a pointer in the above way
there is a class
class ABC; and pointer ptr is present in this class

ABC abc //handle
Now could I pass ptr in following way?
trans.set_data_ptr((unsigned char*)(&abc.ptr));

or

trans.set_data_ptr((unsigned char*)(abc.ptr[0]));//

Regards
cam
Last edited on
If ABC::ptr is a pointer, and is public you can pass it like:

1
2
3
4
5
trans.set_data_ptr((unsigned char*)(abc.ptr));

// or to make the cast more obvious

trans.set_data_ptr(reinterpret_cast<unsigned char *> (abc.ptr));


Note that this is probably not "passing by reference".
It is probably passing by value, even if it's a pointer being passed.
I don't see the code for set_data_ptr() to know for sure.
Last edited on
Topic archived. No new replies allowed.