jmasterx jmasterx - 1 year ago 72
C++ Question

std::string == not working?

When I do:

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

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 ?


Answer Source

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*

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download