Re: abstract class
Re: abstract class
- Subject: Re: abstract class
- From: Daniel Child <email@hidden>
- Date: Fri, 25 May 2007 01:04:39 -0400
Shawn,
If you provide no implementation code for someAbstractMethod under
AbstractClass, then when the user calls
AbstractClass * myNewObject = [[AbstractClass alloc] init];
[myNewObject someAbstractMethod];
how is it going to get booted down to the subclass's implementation
of someAbstractMethod (the one which does the work)?
On May 24, 2007, at 12:00 PM, Shawn Erickson wrote:
You can do this using various patterns... so the following is just one
example and likely the laziest of them. You can take further steps to
actually flag incorrect usage at runtime (attempts to instantiate the
base class, etc.) but often those are over kill IMHO.
// document that the following class is abstract
@ interface AbstractClass : NSObject {
...
}
- (void) someAbstractMethod;
... other methods ...
@end
@implementation AbstractClass
// document that the following method is abstract
- (void) someAbstractMethod {}
@end
@interface ConcreteClass : AbstractClass {
...
}
... other methods ...
@end
@implementation ConcreteClass
- (void) someAbstractMethod {
... implementation ...
}
@end
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden