Can programming Indices be a veriable type like int, float in some way?

Can programming Indices be a veriable type like int, float in some way?
If you meant the value you use to indicate different elements of an array, they can be int values only.
I'd like to see the scenario where you would want to use a decimal to indicate what part of an array you are trying to address though. I have a feeling that either you are misunderstanding arrays or you are trying to do something the wrong way.
It's like in Harry Potter where they are trying to get into that gate in between gates. Was like gate 1 3/4. I imagine accessing arrays with a floating point is similar to that, you end up in a magical land full of wizards and owls. :D
I imagine accessing arrays with a floating point is similar to that, you end up in a magical land full of wizards and owls. :D


If by 'wizards' you mean compilation errors and 'owls' you mean a sore backside from kicking yourself then I'd agree. :-)

To the OP, in case there's a little confusion in what you're asking, you can also use a declared integer as an array index:

1
2
3
4
int my_index = 2;
int my_array [10];

cout << "Value at 3rd array entry = " << my_array[my_index];


Of course, I haven't stored anything in that array so you'll get junk back. But you get my point. ;-)
Topic archived. No new replies allowed.