Compiler Error 349
no operator ... matches these operands
This is a generic error thrown when you try and perform an operation on a type instance that has no implementation. For example trying to perform bitwise operations on a generically defined class.
Below is a list of common causes of such an error and possible solutions to them.
no operator "==" matches these operands
main.cpp
#include "mbed.h" #include <string> int main() { int a = 1; std::string b = "2"; if (a == b) { // <---- no operator "==" matches these operands a = 2; }; }
This does not work because objects of type "int" have no declared method for equality comparison with a type of std::string. There are two common solutions.
- Convert the operand into a type which does have a declared equality comparison operator. In this example you would parse b through a string to integer converter and then compare the resulting integer.
- Define and implement an external equality comparison operator for int with std::string. Usually used when non-standard classes are involved.