Home | News | Documentation | Download

Declaring Variables on the runtime


I want to change the variable names dynamically, on the runtime. I want to create five arrays whose name would be determined on the runtime. How can we do?
Thank you


You cannot change variable names at runtime. Use a std::map instead.


How to use ?
Could you please guide?

map<string, vector<int>> m;


// now renaming worlxd to world (overwriting previous "world"):
auto it = m.find("worlxd");
m["world"] = std::move(it->second);


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.