|
![](/i/fill.gif) |
Kyle wrote:
> I haven't read the whole article yet, only up to the first example, but
> am wondering why not just use a new class that inherits the string class
> and add an email check function there?
Because every function that currently returns a string doesn't have your
extra code added. Every read from a file, every concatenation of two
strings, every string literal, every element on a web page, every attribute
from an XML file, every packet from a socket: all need to get converted to
your type before you can use them.
The "email check" function might be a poor example.
Think of a "point" object, where you want to be able to calculate the
distance, for example. Now you have rectangles holding points, windows
holding rectangles, etc., and you have extra syntax to turn the points in
the rectangles in the windows into MyPoint objects, just so you can apply
the method. Or using a separate function unrelated to points and which
doesn't show up in intelisense.
Plus, of course, that doesn't work if for some reason you can't inherit from
the object, like it being an integer or something.
--
Darren New, San Diego CA, USA (PST)
"Ouch ouch ouch!"
"What's wrong? Noodles too hot?"
"No, I have Chopstick Tunnel Syndrome."
Post a reply to this message
|
![](/i/fill.gif) |