Example 1: Code: int variable0 = 0; int variable1 = 1; int variable2 = 2; int varabile3 = 3; int someArray[4] = {10, 20, 30, 40}; //now i can access array indices like: someArray[variable0]; someArray[variable1]; someArray[variable2]; someArray[variable3]; Now I would like to do something like example above on the runtime: Example 2: Code: void addVariableName(std::string name) { //add variable name and assign following number to it starting from 0 } addVariableName("variable0"); addVariableName("variable1"); addVariableName("variable2"); addVariableName("variable3"); someArray[/*????*/]; //want to access element 0 here using string "variable0" someArray[/*????*/]; //want to access element 1 here using string "variable1" someArray[/*????*/]; //want to access element 2 here using string "variable2" someArray[/*????*/]; //want to access element 3 here using string "variable3" Is there any way to do it? (in the same time as in example 1)