Magic Numbers In Arrays? – C++ – Stack Overflow

Giving the magic index number a name makes it more obvious to those who have to maintain your code, and helps you to prevent typing the wrong one accidentally. In my example above I assumed your array holds distances from the sun to a planet. The sun would be the zeroth element, thus arrayOfNumbers [kDistanceToSun] = 0.

Read More