home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / std / cplus / 1552 < prev    next >
Encoding:
Text File  |  1992-11-12  |  2.4 KB  |  57 lines

  1. Newsgroups: comp.std.c++
  2. Path: sparky!uunet!mcsun!news.funet.fi!network.jyu.fi!sakkinen
  3. From: sakkinen@jyu.fi (Markku Sakkinen)
  4. Subject: Re: c++ implementation (hard)
  5. Message-ID: <1992Nov12.145426.18594@jyu.fi>
  6. Keywords: c++
  7. Organization: University of Jyvaskyla, Finland
  8. References: <kilitzir.721552974@news.forth.gr>
  9. Date: Thu, 12 Nov 1992 14:54:26 GMT
  10. Lines: 45
  11.  
  12. In article <kilitzir.721552974@news.forth.gr> kilitzir@antigone.csi.forth.gr (Xristos Kilitzirakis) writes:
  13. > ...
  14. >all right by then.The problem is,that any operator between these
  15. >2 classes , can give any of the 4 classes,depending on many
  16. >things , not only the type of operands.for ex.
  17. >a+b --->c|d|a,
  18. >so I cannot define the return type ,before inspecting the operands.
  19. >
  20. >Any suggestions of implementing (reordering,add a new class,
  21. >  forgetting the hole thing, etc).          ^^^^^^^^^^^^^^^
  22. >
  23. >Well , the implementation is 
  24. >a -> m_n matrix
  25. >b-> n-n topelitz matrix (needs only 2*n-1 elems)
  26. >c-> n_n circulant matrix(needs only n elems)
  27. > ...
  28.  
  29. No wonder that this looked like a potential "standards" problem to you.
  30. However, there is a conventional technique to do this kind of thing;
  31. it is applicable to other statically-typed OOPLs as well.
  32. It's described in Stroustrup's second edition: "13.9 Handle Classes".
  33. Essentially, you define a Matrix class with the correct interface
  34. (this is the handle class), and then any number of classes that
  35. implement the different representations, and whose instances
  36. the Matrix objects create and handle "behind the scenes".
  37. They would probably not be actually derived from Matrix.
  38.  
  39. The inconvenient thing here is that you must write all member functions
  40. both in the representation classes and in the handle class (which just
  41. passes most calls to the representation object).  Indeed, a delegation
  42. facility was added to an experimental version of C++ together with
  43. the first implementation of multiple inheritance (described in
  44. Stroustrup's paper in the EUUG Spring Conference proceedings, 1987)
  45. to avoid such chores.  However, it was abandoned because it appeared
  46. to be error-prone in use.
  47.  
  48. ----------------------------------------------------------------------
  49. Markku Sakkinen (sakkinen@jytko.jyu.fi)
  50.        SAKKINEN@FINJYU.bitnet (alternative network address)
  51. Department of Computer Science and Information Systems
  52. University of Jyvaskyla (a's with umlauts)
  53. PL 35
  54. SF-40351 Jyvaskyla (umlauts again)
  55. Finland
  56. ----------------------------------------------------------------------
  57.