home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / cplus / 13374 < prev    next >
Encoding:
Internet Message Format  |  1992-09-08  |  2.2 KB

  1. Path: sparky!uunet!olivea!hal.com!decwrl!deccrl!bloom-beacon!eru.mt.luth.se!lunic!sunic!ericom!ericom!etnkna
  2. From: etnkna@hisoy2.etn.ericsson.se (Aksnes Knut-Havard)
  3. Newsgroups: comp.lang.c++
  4. Subject: Renaming
  5. Message-ID: <ETNKNA.92Sep7212951@hisoy2.etn.ericsson.se>
  6. Date: 7 Sep 92 19:31:01 GMT
  7. Sender: news@ericsson.se
  8. Distribution: comp
  9. Organization: Ericsson Telecom AS
  10. Lines: 54
  11. Nntp-Posting-Host: hisoy2.etn.ericsson.se
  12.  
  13.  
  14. First; I have not been reading this list for a while, so it is
  15. possible, that my ideas have been discussed before
  16.  
  17. ARM Section 10.11c suggest  a renaming mechanism to be used when two
  18. class hierarchies are merged by a common derived class, where the same
  19. name is used in both hierarchies, but with different semantics. 
  20.  
  21. Such a renaming scheme is of interest in another situation too;
  22. sometimes you want to inherit the same class twice, the classical
  23. example is an implementation of a sparse matrix using linked lists,
  24. each element shall be in one row list and one column list. Deriving
  25. linked list twice is not allowed; There are no way to access the
  26. members of the two parent classes in a unambiguous way.
  27.  
  28. A kludge around this problem is to generate a dummy class inherited
  29. from the parent class and derive both the parent class and the dummy.
  30. The problem with this kludge is that it clobbers the global name
  31. space.
  32.  
  33. The same problem is well known in the relational database world, when
  34. a query needs to reference the same table twice. The solution is also
  35. well known: An alias for one of the tables is created (The ISO SQL
  36. standard uses the term correlation name.) 
  37.  
  38. An example in pseudo c++ shows what I mean.
  39.  
  40. class LinkedListElem;
  41.  
  42. class MatrixElem: public LinkedListElem row, public LinkedListElem column{
  43.     .
  44.     .
  45.     .
  46. };
  47.  
  48. using row:: and column:: internally in Matrix and derived classes to
  49. resolve ambiguity
  50.  
  51. or 
  52.  
  53. class Matrix: public LinkedListElem row, public LinkedListElem{
  54.     .
  55.     .
  56.     .
  57. };
  58.  
  59. using row:: and LinkedListElem::
  60.  
  61. --
  62.  
  63. -------------------------------------------------------------------------------
  64. Name:    Knut-Hevard Aksnes (ECMA 94) or        Knut-Haavard Aksnes (ASCII)
  65. Ericsson signature: HI/ETN/U/IT KNA        Phone: +47 41 19481
  66. Email: etnkna@hisoy.etn.ericsson.se (internet)  ETN.ETNKNA (memo)
  67.