I am learning C++ independently from the tutorial.pdf from this site, and up to this point it has been going great, but I have encountered something I cannot understand in the section on arrays:
"Some other valid operations with arrays:
billy[0] = a; billy[a] = 75;
b = billy [a+2];
billy[billy[a]] = billy[2] + 5;"
I understand the first line; assigning the value of variable a to the first element of the array billy. I am completely lost after this because the tutorial does not explain what billy[a] means. it looks like it is accessing the a element of billy but that is impossible because there is no a element, only billy[0] billy[1] billy[2] billy[3] and billy[4]. What am I missing here?
I'm sorry, I just started yesterday and I'm not quite sure I get what your saying. Are you saying that the array can be accessed by a variable with a value that corresponds to the variables index number? sorry if i said that wrong, I am not quite sure on what words to use
if a = 4 then billy[4] and billy[a] would be the same?
You are already using variables for example to name the array. The same way you can use integral variables as indexes instead of hard-coded integral literals.