Right, but those are pretty simple examples.  If you were to create a 
set of custom objects, you can dictate what makes one objects equal, 
greater than, less than, etc...  It could potentially neaten up code and 
IMHO is a little more elegant than tacking on more methods to the object.

That being said, I've yet to use operator overloading for anything ;-)

S. Isaac Dealey wrote:

>Thanks Matt,
>
>You're right, I misread it... This makes a lot more sense...
>
>Though I'm not sure I see a real advantage to it... I mean...
>Fullnames = FirstNames + LastNames might just as easily be written
>Fullnames = ArrayMerge(Firstnames,Lastnames) or
>Fullnames.setNames(Firstnames,Lastnames)
>
>It's certainly interesting tho.
>
>  
>
>>You may be missing the point with operator overriding.  It
>>exists to allow
>>new classes to use the operators in a manner that is
>>familiar but not
>>intrinsically understood by a computer.
>>    
>>
>
>  
>
>>Say for instance you've written a class that is simply a
>>list of names
>>contained in an array.  You could have three instances of
>>this class -
>>Firstnames, Lastnames, and Fullnames.  Consider this
>>operation:
>>    
>>
>
>  
>
>>Fullnames = Firstnames + Lastnames;
>>    
>>
>
>  
>
>>In most languages, this would not make any sense.  It's
>>not even easily
>>understood by a human as to the function of this list.
>>But you can define
>>the operation of the + sign to be any number of things:
>>    
>>
>
>  
>
>>1)    Firstnames:     Issac, Matthew
>>      Lastnames:      Dealey, Small
>>      Fullnames:      Issac Dealy, Matthew Small
>>    
>>
>
>
>  
>
>>2)    Firstnames:     Issac, Matthew
>>      Lastnames:      Dealey, Small
>>      Fullnames:      Issac, Matthew, Dealey, Small
>>    
>>
>
>  
>
>>3)    Firstnames:     Issac, Matthew
>>      Lastnames:      Dealey, Small
>>      Fullnames:      IDsesaalcey, MSamtatlhlew
>>    
>>
>
>  
>
>>2)    Firstnames:     Issac, Matthew
>>      Lastnames:      Dealey, Small
>>      Fullnames:      Issac, Dealy, Matthew, Small
>>    
>>
>
>  
>
>>Keep in mind that this operator overriding will only be
>>effective for this
>>particular class.  C= A + B where A, B, C are integers
>>will still be normal
>>addition.
>>    
>>
>
>  
>
>>- Matt Small
>>    
>>
>
>
>
>s. isaac dealey   954.522.6080
>new epoch : isn't it time for a change?
>
>add features without fixtures with
>the onTap open source framework
>
>http://macromedia.breezecentral.com/p49777853/
>http://www.sys-con.com/author/?id=4806
>http://www.fusiontap.com
>
>
>
>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Sams Teach Yourself Regular Expressions in 10 Minutes  by Ben Forta 
http://www.houseoffusion.com/banners/view.cfm?bannerid=40

Message: http://www.houseoffusion.com/lists.cfm/link=i:5:155199
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/5
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:5
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.5
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to