Variable Names based on Variable Values
greetings,
i wasnt to sure what to name the subject but what im trying to do is basically display variables based on the value of another variable. consider this...
char Name1[10] = "Test1";
char Name2[10] = "Test2";
int Value = 2;
now rather than doing
switch(Value)
{
case 1:
cout << Name1 << endl;
break;
case 2:
cout << Name2 << endl;
}
could i instead do somethign along the lines of
cout << NameValue << endl;
ie. appending the value of "Value" in this case "2" to that of Name and thus printing the value of Name2 ?
im trying to do this with structures so i have enemies1, enemies2, enemies3, etc, etc based on what level player is on. Therefore rather than using switch and cases if I coudl just append the value of what level they are on to "enemies" and thus pulling the correct data.
I have dont this before in PHP but not sure if its possible with C++.
I hope you can understand what i mean.
Thanks in advance for any advice given.