By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,510 Members | 1,821 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,510 IT Pros & Developers. It's quick & easy.

create a variable of certain name

P: 3
Hi, I was thinking how to solve this "big problem":

I have some string (or any variable) : string s = "geek", and now I want do create a new string which is named like the content of string s (I could simply write: string geek = "something", but I don't know the name geek beforehand).


Thanks very much for any idea
-oneshed-
Aug 4 '07 #1
Share this Question
Share on Google+
1 Reply


Expert 10K+
P: 11,448
Hi, I was thinking how to solve this "big problem":

I have some string (or any variable) : string s = "geek", and now I want do create a new string which is named like the content of string s (I could simply write: string geek = "something", but I don't know the name geek beforehand).


Thanks very much for any idea
-oneshed-
You can't do that; after compilation is over and done with, the number of variables
as well as their names are known and there is no chance that you can add a new
variable (and name) at runtime. You could use a map with strings and values
though. Read the STL documentation.

kind regards,

Jos
Aug 4 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.