Stewart Smith wrote:
> On Thu, Mar 26, 2009 at 10:42:24AM -0700, Eric Day wrote:
>> It's nice knowing what type of var you are referencing in code without
>> having to look at the class definition.
> 
> 176% agree.

95% agree... it would be 100%, but I don't think we need to go Hungarian
 or anything.

> If what code does is not obvious by looking at it, it's crappy code
> (this is why operator overloading is the root of all evil).

To be argumentative though...

Operator overloading isn't always bad. It's pretty much required for
efficient use of some STL algorithms. And I'd argue:

class Date
{
  Date& operator+=(const Date& arg)
  {
    my_special_internal_date_value +=
      arg.my_special_internal_date_value;
    return *this;
  }
};

should cause no problems, given that you are making the + operator
behave like the plus operator in exactly the way you'd expect a +
operator to work.

On the other hand, having:

class Foo
{
  Foo& operator+=(uint32_t arg)
  {
    pthread_abort(random_thread_list[arg]);
    return *this;
  }
};

would, indeed, be one of the evilest things ever and should die a
violent death.

Monty

_______________________________________________
Mailing list: https://launchpad.net/~drizzle-discuss
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~drizzle-discuss
More help   : https://help.launchpad.net/ListHelp

Reply via email to