Operator Overriding (Re: Operator Overloading <<)
- From: "Robert Klemme" <bob.news@xxxxxxx>
- Date: Fri, 30 Sep 2005 10:25:54 +0200
Brian Mitchell wrote:
> On 9/30/05, Robert Klemme <bob.news@xxxxxxx> wrote:
>> Austin Ziegler wrote:
>>> On 9/29/05, matt.hulse@xxxxxxxxx <matt.hulse@xxxxxxxxx> wrote:
>>>> Is there a way to overload '<<' in the Array class?
>>>>
>>>> Or perhaps there's a better approach to my problem. I have a class
>>>> that inherits from Array. I want the user to be able to use my
>>>> class just like a standard array. However, I want to be able to
>>>> force some code to run every time a user of my class appends a new
>>>> item. I was able to overload the '+' operator to do this but it
>>>> doesn't fit with standard array usage.
>>>
>>> It's generally not considered a good idea to overload. Consider
>>> using Delegate instead.
>>
>> Pardon me, but this is nonsense: Matt has *inherited* Array. Of
>> course you can argue about whether *that* is reasonable, but once
>> you did that providing your own implementation of a super class
>> method in a derived class is completely standard OO. There's even a
>> keyword to support this ("super").
>>
>> If you wanted to question the practice of inheriting classes like
>> Array and String then I'm completely with you. This doesn't make
>> sense more often that it does. But I know too little of this
>> particular case to further comment on that.
>>
>> Kind regards
>>
>> -r :-)
>>
>
> It seems like this thread ought to consider the differences between
> overloading and overriding. They are most certainly not the same.
True. We used the wrong term. But if I'm not mistaken everybody was
actually talking about overriding so far - even if they used the wrong
word. Thanks for reminding us!
Kind regards
robert
.
- References:
- Operator Overloading <<
- From: matt.hulse@xxxxxxxxx
- Re: Operator Overloading <<
- From: Austin Ziegler
- Re: Operator Overloading <<
- From: Robert Klemme
- Re: Operator Overloading <<
- From: Brian Mitchell
- Operator Overloading <<
- Prev by Date: Re: [ANN] Rapid GUI Development with QtRuby
- Next by Date: Re: Win32API question
- Previous by thread: Re: Operator Overloading <<
- Next by thread: Re: Operator Overloading <<
- Index(es):
Relevant Pages
|