Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 9671e07d03
Fetching contributors…

Cannot retrieve contributors at this time

21 lines (19 sloc) 0.744 kb
\begin{Exercise}[title={Pointers and reflection},difficulty=1]
\label{ex:pointers and reflection}
\Question
One of the last paragraphs in section ``\titleref{sec:introspection and reflection}''
on page \pageref{sec:introspection and reflection}, has
the following words:
\begin{quote}
The code on the right works OK and sets the member \var{Name}
to ``Albert Einstein''. Of course this only works when you call \func{Set()}
with a pointer argument.
\end{quote}
Why is this the case?
\end{Exercise}
\begin{Answer}
\Question
When called with a non-pointer argument the variable is a copy (call-by-value). So you
are doing the reflection voodoo on a copy. And thus you are \emph{not}
changing the original value, but only this copy.
\end{Answer}
Jump to Line
Something went wrong with that request. Please try again.