Re: Is this possible without multiple inheritance?
Re: Is this possible without multiple inheritance?
- Subject: Re: Is this possible without multiple inheritance?
- From: publiclook <email@hidden>
- Date: Fri, 4 Jul 2003 12:33:38 -0400
On Friday, July 4, 2003, at 10:37 AM, Jeff Harrell wrote:
On Friday, July 4, 2003, at 09:23 AM, publiclook wrote:
Anything can be done without multiple inheritance. Anything can be
done without inheritance at all.
Not to pick nits, but that's not completely true. Say for example
there's a library function that takes an NSSet pointer as an argument.
You won't be able to pass anything but an NSSet or an instance of a
subclass of an NSSet to that function; the compiler won't let you.
You can of course cast any pointer to pointer to NSSet, but more to the
point, some object that is not related by inheritance to NSSet (even a
new base class) can still implement all of the methods that NSSet
implements. It could even implement -isKindOfClass: to claim it IS and
NSSet. Using the id type to store a pointer to an instance of such a
class enables you to pass the id to any method requiring and pointer to
an object and you don't even need a cast.
id someObject = [[MYClassUnrelatedToSetButImplementsSetMethods alloc]
init];
[someLibraryObject someMethodThatWantsASet: someObject];
It works fine at compile time and runtime. Dynamic typing is a GOOD
thing.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.