|
-
March 29th, 2011, 04:12 AM
#2
Re: Inheriting Constructors
Frankly I do not understand to what use-case your train of thought is implying...
Code is code, while runtime, it is already totally in place. There is nothing left that is "abstract" at all.
Any extending class must implement least one of the constructors available in the super class. There is no requirement as such to implement all. Thus any extending class will inherently do what you ask "be restricted to specified set of constructors". This requirement to have a constructor as such behaves for all shits and giggles musch like an abstract method.
The constructor must be callable, so if you say.... would create the base class in package A, have the constructors you do not want the extending classes to implement (but still want them there) as package private and have the extending classes in a different package... only the public constructor options would be accessible.
Only protected constructors, factory methods that create instances using specific constructor and matching set of params. That way you can limit and manage which way instances of your class are actually created.
Last edited by Londbrok; March 29th, 2011 at 04:14 AM.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|