Re: Operator Overloading <<



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 :-)

.



Relevant Pages

  • Re: [Newbie Question] Magic Numbers dangerous?
    ... An experienced Aerospace ... Person A inherits some code from somewhere, and sees an array which is ... size of the table is a prime number, so Person A declares a new constant: ... Person Z inherits the code long after Person A has passed ...
    (comp.lang.java.programmer)
  • Overwrite a property of ArrayList - Error
    ... a couple of days ago I tried to write a class that inherits from ArrayList ... and overwrites some members in order to get a type save array for my ...
    (microsoft.public.dotnet.languages.vc)
  • Re: Operator Overloading <<
    ... Subject: Operator Overloading << ... Is there a way to overload '<<' in the Array class? ... like a standard array. ...
    (comp.lang.ruby)
  • Re: Operator Overloading <<
    ... >>> that inherits from Array. ... >>> just like a standard array. ... > providing your own implementation of a super class method in a derived ...
    (comp.lang.ruby)
  • Operator Overloading <<
    ... Is there a way to overload '<<' in the Array class? ... that inherits from Array. ... just like a standard array. ...
    (comp.lang.ruby)