std::string == not working?
std::string == not working?
当我这样做时:
std::string name = targetBone->getName();
if(name == "Pelvis")
{
return;
}
我得到:
Error 1 error C2678: binary '==' : no operator found which takes a left-hand operand of type 'std::string' (or there is no acceptable conversion)
如何解决此错误?
感谢
是否在cpp文件中包含字符串
#include <string>
这通常是因为编译器需要查看包含文件中的字符串类的定义,以验证它是否确实声明了一个接受char*
您可能缺少
#include <string>
此外,为了比较字符串,您应该使用strcmp()内置函数,而不仅仅是使用运算符。
相关文章:
- GDB - strcmp not working: __strcmp_sse2_unaligned
- QT qScriptConnect is not working
- QDesktopServices::openUrl() not working Qt
- "Configure: Error: Could Not Find a Working Compiler, See config.log For Details"
- C++ std::set ordering not working with customer class*
- C++ SetWindowText not working
- visual studio 2012 c++ hello world - iostream not working
- getGravity not working?
- Opencv findcontours CV_RETR_EXTERNAL not working
- c++ srand() not working
- std::queue::empty() not working?
- BCB swprintf not working
- 将类型作为指向另一个类的对象的指针的泛型类-NOT WORKING
- LoadLibrary is not working
- gluUnProject not working
- C++ catch bad_alloc not working
- updatelayeredwindow not working
- OpenMP set_num_threads() is not working
- glOrtho not working
- Cuda atomicInc not working