Const pointers: Logical consequences
Consider this follow-up question to the question from last time:
When I call the
PropertySheetfunction, can I assume that the
phpagefield of the
PROPSHEETHEADERstructure will not be modified?
If we take a look at the declaration of the
function, we see that it reads like this:
typedef const PROPSHEETHEADERA *LPCPROPSHEETHEADERA; typedef const PROPSHEETHEADERW *LPCPROPSHEETHEADERW; WINCOMMCTRLAPI INT_PTR WINAPI PropertySheetA(LPCPROPSHEETHEADERA); WINCOMMCTRLAPI INT_PTR WINAPI PropertySheetW(LPCPROPSHEETHEADERW);
Go past all the function declaration specification goo and look
at the parameter list.
const pointer to a
structure (either ANSI or Unicode, depending on which flavor of
PropertySheet function you’re calling).
One of the rules for const pointers is that you can read from them
but you cannot write to them.
PropertySheet function is not allowed
to modify the
Assuming your code doesn’t modify the
any value on exit from the function will be the same
as the value it had on entry.