The answer to the question here addresses initializing a null-reset or zero struct.
How can I check equality though?
say my struct x is defined as follows:
struct MyStruct {
int a;
int b;
};
and the empty struct :
static const struct MyStruct EmptyStruct;
how do I check equality inside a function that takes a reference to a struct of type x?
void myFunction (... , MyStruct &x, ...){
//some code
if (x != EmptyStruct){ // this doesn't work (see error below)
}
//some code
}
The error I get when I try the above:
no match for 'operator!=' in 'x != EmptyStruct'
EDIT: to make it more clear I understand the error message in terms of overloading the != operator for the struct but since an EmptyStruct is a special kind, how can I deal with that?
I guess the point is that a struct of my type with a = 0 and b = 0 is not the same as the EmptyStruct which should represent null-like struct.