Hello everyone
Is it possible to use a variable for a vector name
eg

MyVar.push_back(line);

Recommended Answers

All 2 Replies

Not sure I understand the question....

Assuming line is a string,
Then:
string line="WHATEVER";
vector<string> myVar;
myVar.push_back( line );

should be perfectly acceptable. Is that what you're asking?

Is it possible to use a variable for a vector name

To me it sounds like you may want a std::map.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.