根据http://www.cplusplus.com/reference/map/map/,我可以使用m[k]或m.at(k)访问k地图中某个键的值m.但是,当我尝试做的时候
derivMap[fx]
Run Code Online (Sandbox Code Playgroud)
在我的代码中,derivMap是std::map<std::string,std::string>Visual Studio 2013 类型的元素,它给了我警告
没有operator []匹配这些操作数
但是,当我将代码更改为
derivMap.at(fx)
Run Code Online (Sandbox Code Playgroud)
我没有错.你对这个问题有什么了解吗?
我的下面(不完整)函数的语句出现错误“表达式必须具有整数或枚举类型”switch。我盯着它看了一会儿,不知道是怎么回事。任何见解非常感谢。
std::string CWDriver::eval_input(std::string expr)
{
std::vector<std::string> params(split_string(expr, " "));
std::string output("");
if (params.size() == 0)
{
output = "Input cannot be empty.\n";
}
else
{
switch (params[0])
{
case "d":
}
}
}
Run Code Online (Sandbox Code Playgroud) 在我的代码中我有
switch (cd->op)
{
...
}
Run Code Online (Sandbox Code Playgroud)
而且我想知道我是否应该这样做
CalcWizConsts::eqOps thisOp = cd->op;
switch (thisOp)
{
...
}
Run Code Online (Sandbox Code Playgroud)