Let's say I have 15-20 float variables that are included in a Person class. Each of those float variables are counting something different (e.g : var_0 : count_cats, var_1 = count_dogs, ..., var_19 = count_X).
I currently have those variables in a class like this :
class Person {
double count_cats;
double count_dogs;
etc...
}
I would like to know if there is a way I could put those variables in a kind of container where I could iterate over all of them when needed, but where I could still access the variables by their names (I don't want to have a vector<double> vec_count
and have vec_count[0] representing count_cats, vec_count[1] representing count_dogs, etc.)
Thanks !