Is it possible to declare a variable with the name of the value of another variable(a string). For example have a string containing the word 'abc' and then declare a variable with the value of string so in this case the variable is called abc???
Is it possible to declare a variable with the name of the value of another variable(a string). For example have a string containing the word 'abc' and then declare a variable with the value of string so in this case the variable is called abc???
No. Such things work in scripting languages only.
Kurt
If you know what the type is going to be, you could use a std::map
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
Use std::map<std::string, X> where X is whatever type of the variable you want it to be.
There are actually several good examples of this on the board if you can find them in a search.
Just FYI -
Regular variable names are only used in your high-level source code. They don't exist in the (machine language) EXE file. The machine language program keeps track of variables by keeping track of their location in memory... by keeping track of their addresses.