suppose you have three global vectors V1, V2, and V3.
suppose you have a function which performs a set of actions, such as VN[3]++, on one of the above vectors determined by an int value.
in python i would do something like:
global:
v1 = [1,2,3]
v2 = [1,2,3]
v3 = [1,2,3]
lists = [v1, v2, v3]
def function (determiner):
list = lists[determiner]
list[1] += 1...
I think in theory i could just have separate ifs for each possible value of determiner, but it seems like bad code to repeat a length of code multiple times. (1) What is the correct way to approach this problem? I assume I would use pointers, but I've just learned about them today and i've been struggling to get my code to work. Here's a sample of the code i've been trying.
vector <int> counts0;
vector <int> counts1;
void editor(int determiner){
if (determiner == 1) {
vector<int> & count_l = counts1;
}
else if (determiner = 2) {
vector<int> & count_l = counts2;
}
count_l[5]++;
}