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-27 07:08:19 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!nycmny1-snh1.gtei.net!news.gtei.net!newsfeed.mathworks.com!nntp.abs.net!uunet!dca.uu.net!ash.uu.net!spool0900.news.uu.net!reader0902.news.uu.net!not-for-mail Date: Mon, 27 Jan 2003 10:08:17 -0500 From: Hyman Rosen User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.3a) Gecko/20021212 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: <_VkW9.266404$FT6.43771824@news4.srv.hcvlny.cv.net> <1043339266.922562@master.nyc.kbcfp.com> <7iLY9.2401$qb1.464@nwrddc01.gnilink.net> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Organization: KBC Financial Products Message-ID: <1043680098.61106@master.nyc.kbcfp.com> Cache-Post-Path: master.nyc.kbcfp.com!unknown@fixedcost.nyc.kbcfp.com X-Cache: nntpcache 3.0.1 (see http://www.nntpcache.org/) NNTP-Posting-Host: 204.253.250.10 X-Trace: 1043680098 reader2.ash.ops.us.uu.net 11789 204.253.250.10 Xref: archiver1.google.com comp.lang.ada:33454 Date: 2003-01-27T10:08:17-05:00 List-Id: Dmitry A. Kazakov wrote: > If I define a method or a free a procedure on Ellipse: > void Foo (Ellipse& A); > then the compiler will not substitute a Circle for Ellipse. Oh, You want to do *that* :-) It's an odd sort of thing to want to do, but if you did, you wouldn't do it with copy-in/ copy-out, at least in C++. If I had to, I would do it like this, in typical OO fashion: struct EllipseInterface { virtual void set(double x, double y) = 0; virtual void get(double &x, double &y) const = 0; }; class Ellipse : public EllipseInterface { double X, Y; public: Ellipse(double x, double y) : X(x), Y(y) { } void set(double x, double y) { X = x; Y = y; } void get(double &x, double &y) const { x = X; y = Y; } }; class Circle : public EllipseInterface { double R; public: struct NotCircle { }; Circle(double r) : R(r) { } void set(double x, double y) { R = x == y ? x : throw NotCircle(); } void get(double &x, double &y) const { x = R; y = R; } }; void Foo (EllipseInterface &A);