home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.lang.modula3:843 comp.lang.misc:2685 comp.lang.c++:11262
- Path: sparky!uunet!haven.umd.edu!darwin.sura.net!mips!pacbell.com!network.ucsd.edu!lyapunov.ucsd.edu!mbk
- From: mbk@lyapunov.ucsd.edu (Matt Kennel)
- Newsgroups: comp.lang.modula3,comp.lang.misc,comp.lang.c++
- Subject: Re: Sather's Multiple Inheritance
- Date: 21 Jul 1992 20:04:41 GMT
- Organization: Institute For Nonlinear Science, UCSD
- Lines: 92
- Message-ID: <14hqkpINN3h6@network.ucsd.edu>
- References: <ARI.HUTTUNEN.92Jul20112548@wonderwoman.hut.fi>
- NNTP-Posting-Host: lyapunov.ucsd.edu
- X-Newsreader: Tin 1.1 PL3
-
- Ari.Huttunen@hut.fi (Ari Juhani Huttunen) writes:
- : In article <147qlkINNft3@network.ucsd.edu> mbk@lyapunov.ucsd.edu (Matt Kennel) writes:
- :
- : ! Now what if both PARENT_CLASS_ONE and PARENT_CLASS_TWO
- : ! have two features, say integer variables "count":
- :
- : ! Then you can use "alias new_name old_name":
- : ! ===========
- : ! class CHILD is
- :
- : ! PARENT_CLASS_ONE; --- That inherits it
- : ! alias count_one count; --- rename "count" from P_C_O
- : ! PARENT_CLASS_TWO; --- That inherits another
- : ! alias count_two count; --- Rename that one as well
- :
- : ! count : INT; --- A third "count" different from the
- : ! --- other two.
- :
- : ! end;
- : ! ============
- :
- : ! I don't know if this solution is perfect for all circumstances, but it
- : ! appears to a layman to cover a whole lot, and it's very easy to understand.
- :
- : You still have the problem that CHILD, PARENT_CLASS_ONE and PARENT_CLASS_TWO
- : refer to the same 'count' each, unless you re-rewrite the functions in
- : the parent classes. (In some cases this would be desirable, in others it
- : would not.)
- :
- : The problem would be solved, if this were possible: 'rename count_two count'.
-
- I think there's a bug in the compiler, actually. As you were, I wasn't able
- to override an integer feature (storage) with a procedure, but I was
- able to override that same integer feature with a feature of different type.
- ============================
- class FATHER is
-
- private xyz:INT;
-
- foobar is
- xyz := 123;
- end; -- foobar
-
- end; -- FATHER
-
- class CHILDBAD is
-
- FATHER;
- alias father_xyz xyz;
-
- xyz:DOUBLE is
- res := 1.0;
- end; -- xyz
-
- end; -- CHILDBAD
-
- class CHILDGOOD is
-
- FATHER;
- alias father_xyz xyz;
-
- xyz:DOUBLE;
-
- end; -- CHILDGOOD
-
-
- class TEST is
- main is
- a:FATHER;
- a.foobar;
-
- b:CHILDGOOD;
- b.foobar;
-
- -- c:CHILDBAD;
- -- c.foobar;
- -- Compiler gives an error if you uncomment these lines! ???
- --
- end;
-
- end;
-
- ===================================
-
- : --
- : ...............................................................................
- : Ari Huttunen They say the sky high above
- : 90-7285944 is Caribbean blue... (Enya)
-
- --
- -Matt Kennel mbk@inls1.ucsd.edu
- -Institute for Nonlinear Science, University of California, San Diego
-