jmasterx jmasterx - 1 month ago 6
C++ Question

std::string == not working?

When I do:

std::string name = targetBone->getName();
if(name == "Pelvis")
{
return;
}


I get:

Error 1 error C2678: binary '==' : no operator found which takes a left-hand operand of type 'std::string' (or there is no acceptable conversion)


How do I resolve this error ?

Thanks

Answer

Have you included string in your cpp file

#include <string>

This usually happens because the compiler need to see the definition of string class that resides in that included file to verify that it indeed declares an operator that takes a char*

Comments