On Aug 29, 2005, at 6:33 PM, Juergen Schreck wrote:
On Aug 29, 2005, at 6:11 PM, William Squires wrote:
Polymorphism. A method can declare the type of one of its arguments
as 'Object' and that'll allow a reference (including nil) to any
class to be valid. Let's say you have two classes, 'A' and 'B'.
Neither is a subclass of the other, and you want to allow a method
(sub or function) to take an instance of either and print it to the
screen with the MsgBox function, after some fancy formatting, etc...
snip...
I understand what you're saying. But it still doesn't explain why
you'd want to 'new' an object.
I'm not saying to 'New' a reference to "Object", as you can't - it's
an abstract class; intended only to be subclassed. You 'New' a
reference to some other subclass (that's not abstract), then assign the
reference thereof to a variable (or array) of type
'reference-to-Object' so that you can take advantage of polymorphism
without type-mismatch errors.
As for "objects" (note the difference in capitalization here...), how
else would you get an instance, besides "New"? The only other two ways
are:
1) from an already existing instance, which itself has this
restriction, or
2) from a factory method, such as NewMemoryBlock(), GetFolderItem(), or
some such.
Regards,
Juergen
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
A compiler is a tool for turning source code into error messages;
generating machine language bytes is just a fortuitous by-product!
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
|