pointers and referances
lets say I have a function of type:
void foo(Comm &comm, Report &msg, Name dest)
*notice the two ref symbols...
now I want to call that function and all I have is
Comm * myCom;
Report * myReport;
How do i cast these pointers to ref variables..
Thanks in advance...
[322 byte] By [
wuhoo] at [2007-11-18 20:30:05]

# 1 Re: pointers and referances
foo(*myCom, *myReport, dest);
# 3 Re: pointers and referances
VladimirF gave you another way to do it. which would probably be less confusing to another programmer (i.e. less variables around, that reference the same object).
Viggy
# 4 Re: pointers and referances
Originally posted by wuhoo
i cant change the function defination but this is how your do it...
Foo * myComm =new Foo()
Foo &myComm2 = *myComm;
There is no need for creating two temporary variables as shown by VladimirF...simply use the content operator ('*') on the pointer variables to pass the actual object these pointers are pointing to...