I have a class with nested structures that receive data from two different devices.
class Command
{
public:
struct A
{
uint8_t A_command;
std::vector<std::string> A_fields;
};
struct B
{
uint16_t B_command;
uint16_t B_command_alt;
std::vector<std::string> B_fields;
};
A a_cmd;
B b_cmd;
};
And I would have a loop that receives commands from the devices and process them in this way
...
Command command = {0};
command.a_cmd = get_command_from_device_A();
But when trying to check if some of the structures is different from zero the compiler sends this message
if (command.a_cmd != 0)
{
std::cout << "Command A was received" << std::endl;
}
error C2451: conditional expression of type 'Command::A' is illegal Note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
Is it possible to do a comparison without having to add an additional boolean?
Thanks in advance
Aucun commentaire:
Enregistrer un commentaire