最佳答案
Consider a standard for loop:
for (int i = 0; i < 10; ++i)
{
// do something with i
}
I want to prevent the variable i
from being modified in the body of the for
loop.
However, I cannot declare i
as const
as this makes the increment statement invalid. Is there a way to make i
a const
variable outside of the increment statement?