home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / object / 3379 < prev    next >
Encoding:
Text File  |  1992-09-02  |  1.8 KB  |  41 lines

  1. Newsgroups: comp.object
  2. 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
  3. From: mw@ki.fht-mannheim.de (Marc Wachowitz)
  4. Subject: Re: Implementation Question
  5. Message-ID: <4qknfs-+@aix01.rz.fht-mannheim.de>
  6. Date: Wed, 02 Sep 92 14:33:08 GMT
  7. Organization: Fachhochschule fuer Technik Mannheim
  8. References: <graham.715435125@galois>
  9. X-Newsreader: Tin 1.1 PL4
  10. Lines: 29
  11.  
  12. Graham Matthews <graham@maths.su.oz.au> wrote:
  13. :     class A
  14. :         instance variables a, b, c;
  15. :     end class;
  16. :     class B
  17. :         subclass of class A;
  18. :         instance variables e, f;
  19. :     end class;
  20. : Now my problem is as follows. How do OO implentations handle the 
  21. : space allocation for an instance of class B? Does an instance of B
  22. : have to have space allocated for all the instance variables in B as 
  23. : well as all the instance variables in all the classes of which B is 
  24. : a sub-class (in this case class A).
  25. As subclassing is usually understood, that's exactly what you asked the system
  26. to do. B is a subclass of A simply means that each instance of B is also of
  27. type A, and thus should have the instance variables (assuming classes act both
  28. as type specifications and as implementation descriptions).
  29.  
  30. The usual solution would be to change your class relations appropriately; e.g.
  31. create an abstract class (i.e. one which isn't supposed to be instantiated)
  32. with the features of A to be shared with B, then make both A and B subclasses
  33. of the newly created class (removing the shared features from A, of course).
  34. This shouldn't affect old code, and you are telling the system what you really
  35. want.
  36.  
  37. -------------------------------------------------------------------------------
  38. Marc Wachowitz, mw@gandalf.ki.fht-mannheim.de, 75742@novell1.rz.fht-mannheim.de
  39.   *  wonder everyday    *    nothing in particular    *    all is special  *
  40.