1. 0x1 is hexadecimal for the decimal number 1, which is kind of stupid...
2. "return statusFlags & FOUND_FROM_c++" would return statusFlags & 0x1, which equals statusFlags & 1, which equals statusFlags, no matter what.
3. "|=" is a C/C++ operator, called "bit-wise OR assignment" It performs operations on the individual bits, returning if at least one of the two bits being compared is on. Actually, x|=y can be expanded to x=x|y, "|" being an operator called bit-wise OR. The logic table of bit-wise OR (what bit-wise OR assignment is based off of) is as follows:
i wonder why do we want to use bit-wise OR return value. wouldn't it be easier if we just use return 1;
i checked the programs and i was not able to find where initiation of statusFlags happen.
if statusFlags never initiated, will it caused any problem in this case? like segmentation fault.
when statusFlags is not initiated, what is the return value of statusFlags for foundFromc++()?
what i mean is, is there any default value like 0 or space?
if the default value is space, it will return something like this " " & " " |= 0x1
when we return a value with ampersand, '&' sign, how does the program interpret it?
let say, 0 & 1
i am sorry if my questions sound stupid, but i really want to clear my doubts so that i dont have to ask for second times.
A "long" is generally going to be 32-bits or 64-bits on a 64 bit system. The two functions are either getting the value of the LSB (least significant bit) or setting the value of the LSB to 1. I don't know what you are talking about with "space". It is only dealing with integers, not characters. A global int will be set to 0. Local uninitialized variables get garbage.
& and | are "bitwise_and" and "bitwise_or" operators. These perform the corresponding logical operation for each corresponding bit of the operands and return the resulting bits. It s not returning a bitwise_or, it is using statusFlags |= 1 (equivalent to statusFlags = statusFlags | 1) to set the LSB of statusFlags to 1, while leaving the other 31 or 63 bits untouched.
Where did you get this code from anyway? AFAIK, you can't use "++" embedded in identifiers. That will not compile with g++. Also, no semi-colon after declaration of statusFlags.