Why would one overload the && and & operator?
Posted
by
acidzombie24
on Programmers
See other posts from Programmers
or by acidzombie24
Published on 2011-03-06T10:10:58Z
Indexed on
2011/03/06
16:17 UTC
Read the original article
Hit count: 331
operators
The same question goes for | and ||.
Why would one overload or 'use' the & and && operator? The only use i thought of are
- Bitwise Ands for int base types (but not float/decimals) using &
- logical short circuit for bools/functions that return bool. Using the && operator usually.
I cant think of any classes that use those operators. Absolutely none. I know a class might support + (and not '-') which combine two strings together. I seen an object such as datetime overload '-' so two dates can be subtracted to make a timespan (obviously you cant add two dates) but i never seen &, &&, | and || used.
Does anyone know of a use? In any language?
© Programmers or respective owner