I have a series of 12 strings of under 25 characters each.
I have 1 two-digit number for each string.
I would like to be able to access each element with an int (index #) and associate the corresponding two-digit number with the string.
As an example:
Code:
std::string FRUITS[] = {"Fruit1", "Fruit2", "Fruit3", "Fruit4"}; // -through 12...
int QTY[] = {02,09,12,24}; // -one per string
//...so I have 12 of Fruit3 in the example.
I also want to be able to access this 'storage' with a function, which will also access other 'storage' with the same design, but possibly a different number of entries. A loop will be run per entry, which is why I need the total (unknown) number of entries.
Basically I stumbled upon this question trying to learn something else, and do not want to spend the next week learning something, only to find out there is a better way to approach what I am doing.
I guess I would just like to be pointed in the most beneficial direction,
arrays
multidimensional array
vector
list
other?
Also, for curiosity, how would this answer differ if I needed the ability to add elements on the fly? (perhaps a project to play with after this)