字符串到变量名称转换的问题 [英] Problem with string to variable name conversions

查看:76
本文介绍了字符串到变量名称转换的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有将string类型的值赋值为整数的名称,或转换该值或反之亦然?

示例:

int Q = 1;

string member =" member" + Q;

//某种类型名称或转换发生?

int member1 = Q;


任何人都有关于如何做到这一点的一些想法?我尝试了从另一个线程获得的streamstring技术,但这不适用于更改值,只有变量类型的名称。:(

Is there anyway to assign a value of type string to be the name of an integer, or convert the value or vise versa?
Example:
int Q = 1;
string member = "member" + Q;
//some kind of type name or conversion takes place?
int member1 = Q;

Anybody have some ideas on how to do this? I tried the streamstring technique that I got off of another thread, but that does not work with changing values, only names of variable types.:(

推荐答案


无论如何将字符串类型的值赋值为整数的名称,或转换该值或反之亦然?

示例:

int Q = 1;

string member =" member" + Q;

//某种类型的名称或转换发生了什么?

int member1 = Q;


任何人对如何做到这一点都有一些想法?我尝试了从另一个线程得到的streamtring技术,但这不起作用改变值,只改变变量类型的名称。:(
Is there anyway to assign a value of type string to be the name of an integer, or convert the value or vise versa?
Example:
int Q = 1;
string member = "member" + Q;
//some kind of type name or conversion takes place?
int member1 = Q;

Anybody have some ideas on how to do this? I tried the streamstring technique that I got off of another thread, but that does not work with changing values, only names of variable types.:(



你想做某种动态变量命名吗?(我是否正确阅读?)


我建议使用数据结构 - 你只能通过持有地方添加/删除/操纵 - 你不必为每个元素命名......

Do you want to do some sort of dynamic variable naming? (Am I reading that correctly?)

I would recommend using a data structure instead - you can add/remove/manipulate from those only by holding place - you don''t necessarily have to name every element...



你想做某种动态变量命名吗? (我正确地阅读了吗?)


我建议使用数据结构 - 你只能通过持有地方来添加/删除/操纵 - 你不一定有命名每个元素...
Do you want to do some sort of dynamic variable naming? (Am I reading that correctly?)

I would recommend using a data structure instead - you can add/remove/manipulate from those only by holding place - you don''t necessarily have to name every element...



从未听说过它。你能给我一个语法的例子吗?我是新手。

Never heard of it. Could you give me an example of the syntax? I''m pretty new to this.



你想做某种动态变量命名吗? (我正确地阅读了吗?)


我建议使用数据结构 - 你只能通过持有地方来添加/删除/操纵 - 你不一定有命名每个元素...
Do you want to do some sort of dynamic variable naming? (Am I reading that correctly?)

I would recommend using a data structure instead - you can add/remove/manipulate from those only by holding place - you don''t necessarily have to name every element...



还有一件事,我不是要为每个元素命名。我正在尝试制作一个找到每个素数的程序,直到我的comps RAM再也无法处理它。要做这样的事情,我需要将我找到的数字添加到某种类型的STL容器中,然后用每个数字迭代它以试图计算我遇到的每个数字,以通过除以它来检查它是否是素数以前找到的数字。问题是,如果没有分段错误,我就不能这样做,因为我不能每次都自动创建一个新的变量名。


例如:

One more thing, I''m not trying to name every element. I''m trying to make a program that finds every prime number until my comps RAM can''t handle it anymore. To do such a thing, I need to add the numbers I find to an STL container of some kind, then iterate through it with each one in an attempt to factor each number I come across to check if it''s prime by dividing it with previously found numbers. Problem is, I can''t do this without a segmentation error because I can''t make a new variable name everytime automatically.

example:

展开 | 选择 | Wrap | 行号


这篇关于字符串到变量名称转换的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆