flag
is a const
member, so that it can only be initialized, not assigned to, unless there's a cast involved. What results you get depend on what you initialize it with, which you do not show.
flag
is a reference (the &
), so it doesn't keep its own value, but rather holds a value from somewhere else. A reference is simply a different name for another variable (or possibly a value, if it's a const
ref). If you initialize it with a variable called i
, for example, then it's another name for i
. If the value of i
changes, the value of flag
changes. The const
means that nothing in x
can modify it directly, not that the value can't possibly be modified. Again, given no information about the initialization you're doing, it's impossible to explain what's going on.
You did mention that you got different results with FLAG
and FLAG &
, which indicates that you are initializing it with a variable, and the variable is then getting changed. Given more context, we could provide more detail.
Now, if you've provided the actual code, there is no difference between UINT16
and UINT32
, since you've defined them both as unsigned short
. There should be no difference in behavior. If there is, it means that you're providing not only insufficient code to know what's going on, but different code than you're actually getting your results from.