So Google’s not a good choice for looking up examples for overloaded operators like “And” or “Or”, because it tries to parse them as operators to the search query itself. MSDN also provides no examples of how to implement an overloaded And operator, so I’m not certain how to properly overload it for my project.
Does anyone have an example of “And” at minimum? “Or” or “Xor” (or any others) would be a bonus. I’m not certain if I need to overload these operators in my objects just yet, as I’m still building them out and haven’t planned beyond just yet. But having examples around that might get indexed by Google will probably help save the sanity of a lot of people…
You overload the logical operators in the same way that you overload the unary or arithmetic operators.
I can’t actually think of a case where this would be useful at the moment, but for the sake of example, here’s a sample structure that overrides the
AndandOroperators:This MSDN page gives some other examples and further explanation.