【问题标题】:Is it possible to declare a variable as a string? [duplicate]是否可以将变量声明为字符串? [复制]
【发布时间】:2015-06-07 17:19:23
【问题描述】:

所以基本上我想找出什么,以这种情况为例:

std::string input;
Ask user for a string?: Apples
cin >> input;
std::string Apples = "input";

所以基本上,我向用户询问一个字符串,然后创建一个具有该字符串名称的变量。这可能吗?

【问题讨论】:

    标签: c++


    【解决方案1】:

    不,你不能那样做。

    最接近的功能是使用地图。

    std::map<std::string, int> aMap;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-25
      • 1970-01-01
      • 2011-04-17
      • 1970-01-01
      • 1970-01-01
      • 2021-04-15
      相关资源
      最近更新 更多