如何在C++中将vartiables值转换为其他名称?就像在这个PHP片段.
$string = 'testVar';
${$string} = 'test';
echo $testVar; // test
Run Code Online (Sandbox Code Playgroud)
如何使用地图?
#include <iostream>
#include <map>
#include <string>
using namespace std;
map<string, string> hitters;
hitters["leadoff"] = "Jeter";
hitters["second"] = "Damon";
hitters["third"] = "Teixiera";
hitters["cleanup"] = "Matsui";
string hitter = "cleanup";
cout << hitters[hitter] << endl;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
249 次 |
| 最近记录: |