I want to use indirect string id in C++.
As an example, I have a number of AnsiStrings, say :
A1="knife"; B2="Poison"; C5="Rope"; etc
and a string with the name of one of these, say ss="B2";
What I need is a function ff so that
cout<<ff(ss)
will print "Poison"
The value of ss can be anything, so a solution such as
if(ss=="A1")return A1; if(ss=="B2")return B2;...
is not possible.
Thanks again,
This can indeed work if I know before all strings in the program and their content, but this is not the case.
The content of some of the strings is dynamic, i.e. B2 could be "Poison" at some step in the program, and "Strychnine" later, etc.