Re: Beginner's questions
Re: Beginner's questions
- Subject: Re: Beginner's questions
- From: "R. Tony Goold" <email@hidden>
- Date: Tue, 16 Oct 2001 12:42:14 -0400
>
Q) What about abstract class (in the java meaning of abstract class) ?
>
A) I've seen the previous answer and ok but it's still too bad...
The ObjC veterans can probably give you a better answer on how to do this
once you make it clear you really want to do it, but the way I would do it
is:
-(id) init
{
[self autorelease];
if (throw_exception_for_abstract_init)
{
[NSException raise:@"AbstractInstantiationException"
format:@"Attempt to instantiate abstract class: %@.", [self
class]];
}
else
{
NSLog(@"Attempt to instantiate abstract class: %@.\n", [self class]
);
}
return nil;
}
Note: This is not tested code. It may suck at best, but it conveys the
general idea. I'll leave it to others to suggest a better method.
Cheers,
Tony