home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- From: nikki@trmphrst.demon.co.uk (Nikki Locke)
- Path: sparky!uunet!charon.amdahl.com!pacbell.com!ames!sun-barr!cs.utexas.edu!convex!news.utdallas.edu!corpgate!bnrgate!bnr.co.uk!pipex!demon!trmphrst.demon.co.uk!nikki
- Subject: Member function renaming proposal from the ARM
- Reply-To: nikki@trmphrst.demon.co.uk
- Distribution: world
- X-Mailer: cppnews $Revision: 1.20 $
- Organization: Trumphurst Ltd.
- Lines: 57
- Date: Mon, 16 Nov 1992 13:31:40 +0000
- Message-ID: <721945900snx@trmphrst.demon.co.uk>
- Sender: usenet@gate.demon.co.uk
-
- I have a question about an extension to the language to allow programmers
- to specify inheriting and optionally renaming functions. The extension is
- proposed in the ARM 10.11c (pp 236-237).
-
- Let us assume two base classes with name clashes ...
-
- class Lottery {
- // ...
- virtual int draw();
- };
-
- class GraphicalObject {
- // ...
- virtual void draw();
- };
-
- // The suggested extension would allow ...
- class LotterySimulation : public Lottery, public GraphicalObject {
- // ...
- virtual int l_draw() = Lottery::draw;
- virtual void draw() = GraphicalObject::draw;
- };
-
- It is stated in the ARM that such a language extension is not _necessary_,
- and is only worthwhile if the need to resolve such name clashes proves
- common. It strikes me that the workround suggested in the ARM is going to
- cause some loss of efficiency on most compilers around today.
-
- I see another use for this extension (see ARM also 13.1 pp310-312) ...
-
- class Base {
- public:
- // ...
- virtual void set(int i);
- virtual void set(double d);
- virtual void set(char *s);
- };
-
- class Derived {
- public:
- // ...
- void set(int) = Base::set(int);
- void set(double) = Base::set(double);
- virtual void set(char *s);
- };
-
- This will prevent set(int) and set(double) being hidden by set(char *),
- without any loss of efficiency in the calling mechanism.
-
- Now I realise that there is no chance of including this in the current
- standard (lets concentrate on getting it finished), but is it a sensible
- enhancement to the language for some future date ? Or is there an existing
- construct which will do the job without any run-time efficiency penalty ?
-
- --
- Nikki Locke,Trumphurst Ltd.(PC and Unix consultancy) nikki@trmphrst.demon.co.uk
- trmphrst.demon.co.uk is NOT affiliated with ANY other sites at demon.co.uk.
-