home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!olivea!hal.com!decwrl!deccrl!bloom-beacon!eru.mt.luth.se!lunic!sunic!ericom!ericom!etnkna
- From: etnkna@hisoy2.etn.ericsson.se (Aksnes Knut-Havard)
- Newsgroups: comp.lang.c++
- Subject: Renaming
- Message-ID: <ETNKNA.92Sep7212951@hisoy2.etn.ericsson.se>
- Date: 7 Sep 92 19:31:01 GMT
- Sender: news@ericsson.se
- Distribution: comp
- Organization: Ericsson Telecom AS
- Lines: 54
- Nntp-Posting-Host: hisoy2.etn.ericsson.se
-
-
- First; I have not been reading this list for a while, so it is
- possible, that my ideas have been discussed before
-
- ARM Section 10.11c suggest a renaming mechanism to be used when two
- class hierarchies are merged by a common derived class, where the same
- name is used in both hierarchies, but with different semantics.
-
- Such a renaming scheme is of interest in another situation too;
- sometimes you want to inherit the same class twice, the classical
- example is an implementation of a sparse matrix using linked lists,
- each element shall be in one row list and one column list. Deriving
- linked list twice is not allowed; There are no way to access the
- members of the two parent classes in a unambiguous way.
-
- A kludge around this problem is to generate a dummy class inherited
- from the parent class and derive both the parent class and the dummy.
- The problem with this kludge is that it clobbers the global name
- space.
-
- The same problem is well known in the relational database world, when
- a query needs to reference the same table twice. The solution is also
- well known: An alias for one of the tables is created (The ISO SQL
- standard uses the term correlation name.)
-
- An example in pseudo c++ shows what I mean.
-
- class LinkedListElem;
-
- class MatrixElem: public LinkedListElem row, public LinkedListElem column{
- .
- .
- .
- };
-
- using row:: and column:: internally in Matrix and derived classes to
- resolve ambiguity
-
- or
-
- class Matrix: public LinkedListElem row, public LinkedListElem{
- .
- .
- .
- };
-
- using row:: and LinkedListElem::
-
- --
-
- -------------------------------------------------------------------------------
- Name: Knut-Hevard Aksnes (ECMA 94) or Knut-Haavard Aksnes (ASCII)
- Ericsson signature: HI/ETN/U/IT KNA Phone: +47 41 19481
- Email: etnkna@hisoy.etn.ericsson.se (internet) ETN.ETNKNA (memo)
-