There are a number of ways to accomplish this:

1 - Create a class that subclasses from A (call it F), add your 2 methods
there and subclass B and C off of it. A, D and E will have exactly the
methods they need.

2 - For more flexibility, use the command pattern described in "Design
Patterns" by Erich Gamma, Richard Helm, Ralf Johnson and John Vlissides and
turn your new methods into objects. Configure each of the subclasses with
the commands they need at instantiation or other appropriate time.

3 - Leave your inheritance hierarchy the way it is, add the two methods to
class A and override them in the classes that don't need them to simply do
nothing and return.

4 - Change your base class to implement an Interface with the two new
methods. For the classes that don't need it, provide empty methods, for the
classes that need it, provide a real implementation.

Sean

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, April 08, 1999 9:17 AM
> To: [EMAIL PROTECTED]
> Subject: [ND] Inheritence
>
>
> Hi,
> I have a superclass A, from which I've derived 4 sub-classes,
> B,C,D and E. Now the
>        superclass has 4 methods. I need to add 2 more methods for
> sub-classes B and C in
>        the super class. But these methods are not needed by A and
> D. How do I get around
>        this? Is it enough to make the 2 methods protected?
> Thanks.
> Sushovan.
>
> _________________________________________________________________________
>
> For help in using, subscribing, and unsubscribing to the discussion
> forums, please go to: http://www.netdynamics.com/support/visitdevfor.html
>
> For dire need help, email: [EMAIL PROTECTED]
>

_________________________________________________________________________

For help in using, subscribing, and unsubscribing to the discussion
forums, please go to: http://www.netdynamics.com/support/visitdevfor.html

For dire need help, email: [EMAIL PROTECTED]

Reply via email to