tags:

views:

58

answers:

3

What's the precedence in the next expression?

item = (char*)heap + offset;

Is it (char*)(heap + offset) or ((char*)heap) + offset?

+1  A: 
((char*)heap) + offset
Ned Batchelder
+2  A: 

It's ((char *)heap) + offset. Casts have much higher precedence than addition.

Jerry Coffin
This is quite correct, but if it's really unclear to the coder, then I'd recommend actually using the parentheses as shown here.
Steven Sudit
+6  A: 

Cast trumps binary addition.

Precedence Table

Jacob