struct S {
double d1;
double d2;
};
S s1,s2;
what was the reason that
s1=s2; // assignment operator (default defined for PODs, right?)
was valid, but not
if (s1 == s2) // test for equality
Regards,
Hi Hicham
Because the first one is copy assignment operator, but the second one
is equality operator.
The first one is declared and defined by compiler implicitly with
default behavior,
but in equality operator case , you have to declare and define its
behavior explicitly.
Regards,
-- Saeed Amrollahi
If the compiler was to automatically generate code for the equality
comparison (which would apply the equality comparison to every member),
wouldn't the next question be why the compiler is not doing the same for
operator<() and the other comparison operators?
But in that case, how would the compiler implement those operators?