How to use string as variable name in C ++?

Possible duplicate:
Convert string to variable name or variable type

How to use string value as variable name in C ++

string listName = "hari";
string vectorName = "BF_vector_"+listName;
vector<string> vectorName;

vectorName.push_back("Some Value");

How to use the string value ("BF_vector_hari") vectorName as the name of a vector variable.? Thanks in advance.

+5
source share
2 answers

You cannot in C ++.

One thing you can do is use the form std::map<std::string, std::vector>to store the name on a vector map.

+9
source

No.

- . ( , ). ( - ), .

.

+6

All Articles