Jump to content
A.M. Hoornweg

class operator, AND/OR/XOR question

Recommended Posts

Hello all,

 

I see that Delphi supports both bitwise and logical versions of and/or/xor operator overloading, but I'm not 100% sure about the difference between the two concepts. 

Assume I have a certain record type, and that I want to implement "AND", "OR" and "XOR" operators, each resulting in some kind of merge of the original input records.  The syntax I would like to use in my code would simply be "A:=(B OR C);"   

 

Do I need to implement BitWiseOr etc or LogicalOr, and if I implement both, how does Delphi decide which of the two is going to be used?

 

 

Share this post


Link to post

From the Docwiki: 
 

Quote
  • For a logical operator and a bitwise operator using the same symbol, the logical operator is used only when the operands are booleans. Since the type of record for this record operator is not a boolean, a logical operator will only be used when the other operand is a boolean.

 

Oops: too late

Edited by Uwe Raabe

Share this post


Link to post

I did consult the wiki but somehow managed to skip this line of text ten times. It must be monday morning ....

 

Thanks for pointing it out!

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×