错误C2678:'=='二进制:没有找到哪个运算符采用'CSchemaString'类型的左操作数(或者没有可接受的转换)

时间:2012-07-20 14:57:22

标签: c++ .net c++-cli

我正在将项目从VC++6转移到VC++ 2005,在编译时我收到以下错误。

  

错误C2678:'=='二进制:找不到左操作数的运算符   'CSchemaString'类型(或没有可接受的转换)

这是代码;

CSchemaString References("id");
for(j=0;j<=tpChild.GetUpperBound();j++)
{
    if(References == "id") //error C2678: '==' binary: no operator found which takes a left operand of type 'CSchemaString' (or there is no acceptable conversion)

        References = References + intToString(((Component*)tpChild.GetAt(j))->GetComponentID()) +"_"+ ((Component*)tpChild.GetAt(j))->GetName();
    else
        References = References + " id" + intToString(((Component*)tpChild.GetAt(j))->GetComponentID()) +"_"+((Component*)tpChild.GetAt(j))->GetName();
}
if(References != "id") //si references n'est pas vide
    XComponent.AddPlant_Item_Ref(References);



return XComponent;

}

感谢任何帮助。

1 个答案:

答案 0 :(得分:4)

CSchemaString不是字符串。你需要做

References.ToString() == "id"