Member reference base type 'int' is not a structure or union
int is a primitive type, it has no methods and properties.
You call str() on a member variable of type int and what the compiler complains about.
Integers cannot be implicitly converted to string, but you can use std::to_string() in C ++ 11, lexical_cast from boost or the old slow stringstream approach.
std::string to_string(int i) { std::stringstream ss; ss << i; return ss.str(); }
or
template < typename T > std::string to_string_T(T val, const char *fmt ) { char buff[20];
And change the line to:
result += std::string(", \"hue\": ") + to_string(st.value.intValue);
Juan ramirez
source share