Say I have something like...
int sum = 0;
int i = 3;
sum = sum + i;
Would 'sum + i' refer to the value 3? Or does 'sum' just get replaced
with 0 and 'i' with 3 before it gets evaluted as 0 + 3.
Your question is very odd. My best guess is that it reflects a serious
misunderstanding of the relationship between the source code and the
resulting program. But that doesn't make must sense, either - as I
recall, you've shown a considerably higher level of understanding in
previous messages posted to this newsgroup; at least, they were posted
using the same e-mail address.
The line in the source code which says
sum = sum + i;
Tells the compiler to create a program containing machine instructions
for the computer which tell it to perform the following tasks:
1. Retrieve the value currently stored in the variable named 'sum'.
2. Retrieve the value currently stored in the variable named 'i'.
3. Calculate the total of those two values.
4. Store the result into the variable named 'sum'.
Typically, the instructions will not refer to the variables by name.
Each of those variables are assigned to a different location in memory,
and the generated instructions simply refer to that memory location. All
trace of the character strings "sum" and "i" have disappeared by the
time the program has been created (that's not quite true, if the
variables have external linkage or if you compile in debugging mode -
but it's accurate enough for the purposes of this explanation).
Therefore, "0" does not replace "0", because the program doesn't contain
"sum", it contains machine instructions.