问题
What's the precedence in the next expression?
item = (char*)heap + offset;
Is it (char*)(heap + offset)
or ((char*)heap) + offset
?
回答1:
Cast trumps binary addition according to the precedence table.

回答2:
It's ((char *)heap) + offset
. Casts have much higher precedence than addition.
回答3:
((char*)heap) + offset
回答4:
The cast is done first, since it has a much higher precedence. You can look that up in the C precedence table!
来源:https://stackoverflow.com/questions/3354446/c-type-casts-and-addition-precedence