|
|
Tim Chan wrote in message <3bfbf514$1@news.povray.org>...
>Hello, I'm studying C++ on my own and would appreciate some help.
[program snipped]
>I don't understand this line:
>
>**** print(reinterpret_cast<X*>(xp)); ****
>
>why do you pass 'xp' into the cast but not '&xp'....?
xp is of type pointer to int, and you are converting it to the type pointer
to X. &xp would be the address of xp, and would be of type pointer to
pointer to int.
>Because earlier you need to pass the address of x into the cast:
>
>**** int* xp = reinterpret_cast<int*>(&x); ****
Here, x is of type X. &x is the memory address of x, and is of type pointer
to X. The reinterpret_cast converts that to type pointer to int.
--
Mark
Post a reply to this message
|
|