From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,103b407e8b68350b X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-01-28 09:12:17 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!news-peer.gip.net!news.gsl.net!gip.net!nntp.abs.net!uunet!dca.uu.net!ash.uu.net!spool0901.news.uu.net!spool0900.news.uu.net!reader0900.news.uu.net!not-for-mail Date: Tue, 28 Jan 2003 12:11:50 -0500 From: Hyman Rosen User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.3b) Gecko/20030116 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Anybody in US using ADA ? One silly idea.. References: <1043339266.922562@master.nyc.kbcfp.com> <7iLY9.2401$qb1.464@nwrddc01.gnilink.net> <1043680098.61106@master.nyc.kbcfp.com> <3afc3v4uur2kvd53v4ul18b5npjfm188o3@4ax.com> In-Reply-To: <3afc3v4uur2kvd53v4ul18b5npjfm188o3@4ax.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Organization: KBC Financial Products Message-ID: <1043773909.385612@master.nyc.kbcfp.com> Cache-Post-Path: master.nyc.kbcfp.com!unknown@nightcrawler.nyc.kbcfp.com X-Cache: nntpcache 3.0.1 (see http://www.nntpcache.org/) NNTP-Posting-Host: 204.253.250.10 X-Trace: 1043773911 reader0.ash.ops.us.uu.net 11396 204.253.250.10 Xref: archiver1.google.com comp.lang.ada:33500 Date: 2003-01-28T12:11:50-05:00 List-Id: Dmitry A. Kazakov wrote: > But that's another thing. Here, Circle cannot use (inherit) the > methods of Ellipse. It inherits only the abstract methods of > EliipseInterface and thus, have to implement all of them for scratch. > This kills the whole idea of inheritance for code reuse. It's just the way I wrote it here, because I figured Circle didn't need to store two doubles, just one. It could have inherited directly from Ellipse if I'd wanted it that way: class Circle : public Ellipse { public: struct NotCircle() { } Circle(double r) : Ellipse(r, r) { } void set(double x, double y) { if (x != y) throw NotCircle(); Ellipse::set(x, y); } }; Someone can sabotage this version though, by taking a Circle and calling its Ellipse::set method directly. In my other version, that couldn't happen.