I have following statement and it compiles:
static unsigned char CMD[5] = {0x10,0x03,0x04,0x05,0x06};
int Class::functionA(int *buflen)
{
...
int length = sizeof(CMD); + *buflen; // compiler should cry! why not?
...
}
Why I get no compiler error?
Is a valid application of the unary
+operator on anint&, it’s basically a noop. It’s the same as if you wrote this:See here for what the unary
operator+actually does to integers, and here what you can practically do with it.