Variable Names

I am wondering about programs that create multiple objects from the same class using indefinate iterations. Is there any way to use user input to name a variable(i.e. name of an object). If not, how do I go about distinguishing an unknown amount of objects within a program. Is it easiest to create an output file for each iteration and reuse the same object over and over?
I'm not sure what you're trying to do, but try look into std::map. With keys as variable names(strings) and values as objects from your class.
The reference on maps is kind of confusing. Here's a hypothetical: A program creates and manipulates accounts. Each account is an object. There is no way to ahead of time how many accounts might be needed, so I can't just use an array of objects. Should I have an output file for each account or is there a way to dynamically name the object? Maybe the map will work, can you suggest a good site to explain it, the reference on this site is kind of confusing and doesn't show an example in action.
Use a std::vector<>, which is just a C++ wrapper for a dynamic array.

thank you very much. Quite useful.
Is there any way to use user input to name a variable

No.
Topic archived. No new replies allowed.