home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.object
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!wupost!gumby!yale!yale.edu!ira.uka.de!uni-heidelberg!fht-mannheim!frodo.ki.fht-mannheim.de!mw
- From: mw@ki.fht-mannheim.de (Marc Wachowitz)
- Subject: Re: Implementation Question
- Message-ID: <4qknfs-+@aix01.rz.fht-mannheim.de>
- Date: Wed, 02 Sep 92 14:33:08 GMT
- Organization: Fachhochschule fuer Technik Mannheim
- References: <graham.715435125@galois>
- X-Newsreader: Tin 1.1 PL4
- Lines: 29
-
- Graham Matthews <graham@maths.su.oz.au> wrote:
- : class A
- : instance variables a, b, c;
- : end class;
- :
- : class B
- : subclass of class A;
- : instance variables e, f;
- : end class;
- : Now my problem is as follows. How do OO implentations handle the
- : space allocation for an instance of class B? Does an instance of B
- : have to have space allocated for all the instance variables in B as
- : well as all the instance variables in all the classes of which B is
- : a sub-class (in this case class A).
- As subclassing is usually understood, that's exactly what you asked the system
- to do. B is a subclass of A simply means that each instance of B is also of
- type A, and thus should have the instance variables (assuming classes act both
- as type specifications and as implementation descriptions).
-
- The usual solution would be to change your class relations appropriately; e.g.
- create an abstract class (i.e. one which isn't supposed to be instantiated)
- with the features of A to be shared with B, then make both A and B subclasses
- of the newly created class (removing the shared features from A, of course).
- This shouldn't affect old code, and you are telling the system what you really
- want.
-
- -------------------------------------------------------------------------------
- Marc Wachowitz, mw@gandalf.ki.fht-mannheim.de, 75742@novell1.rz.fht-mannheim.de
- * wonder everyday * nothing in particular * all is special *
-