Click to See Complete Forum and Search --> : operator overload
Crazy
04-28-2003, 05:09 PM
Can someone please tell me how 'operator overload' works, and why you'd need them. I'm really looking for a simple but thorough explanation with an example or two (preferably one with the + operator and another with a comparison operator). I'm going quite nuts over this as the author of the book I'm reading hasn't bothered to cover it properly, I actually think he doesn't actually know himself, so is blagging his way through. Please help guys, I'm really going crazy.
Thanks
jeffmott
04-28-2003, 08:15 PM
Operator overload means means a single operator performing different operations depending on how it is used. For example, in JavaScript + can mean addition or concatenation depending on the context.
However, I don't believe this particular operation is overloaded in VB. But I'm no expert with in VB so someone else will have to fill in the rest from here.
Bullschmidt
04-28-2003, 09:30 PM
for(split(//,'))*))91:+9.*4:1A1+9,1))2*:..)))2*:31.-1)4131)1))2*:3)"')) ...
Jeffmott,
Not sure but at first glance it looks like that signature might contain some instances of operator overload... ;)
DaiWelsh
04-29-2003, 11:05 AM
Again, I have no great knowledge of how it works in VB, but in C++ you use operator overloading when creating your own objects to define different behaviours according to the types of the operands. So for example if you defined you own object of type (myobject) with special rules, you could create functions to handle e.g.
(myobject) += (integer);
(myobject) += (myobject);
(myobject) += (char);
so for example if an integer is +'d you might want to do a numeric addition, if a char is +'d you might want to append the value somewhere and if another object of the same type is +'d you might want to implement more complex behaviour to combine the two objects.
Whether it is important to you depends on whether you need to implement this type of complex behaviours?
Certainly VBs internal types must implement this concept, for example a variant must be able to handle different types being combined with it and vice-versa, but whether you need to know the details of this (or whether they are even made public in entirety) I dont know.
HTH,
Dai
Crazy
04-30-2003, 05:57 PM
It's ok guys I have managed to work it out. For the record I was actually referring to operator overloading in C# with ASP.NET.
Thanks for your efforts anyway.