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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1116ece181be1aea X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-09-18 01:35:18 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!feed.news.qwest.net!namche.sun.com!news1brm.central.sun.com!new-usenet.uk.sun.com!not-for-mail From: Ole-Hjalmar Kristensen Newsgroups: comp.lang.ada Subject: Re: Is the Writing on the Wall for Ada? Date: 18 Sep 2003 10:28:14 +0200 Organization: Sun Microsystems Message-ID: References: <3F5F7FDC.30500@attbi.com> <3F6079A9.6080108@attbi.com> <3F60E380.4020307@attbi.com> <3F694186.5060709@crs4.it> NNTP-Posting-Host: khepri06.norway.sun.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: new-usenet.uk.sun.com 1063873695 18091 129.159.112.195 (18 Sep 2003 08:28:15 GMT) X-Complaints-To: usenet@new-usenet.uk.sun.com NNTP-Posting-Date: 18 Sep 2003 08:28:15 GMT User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/21.2 Xref: archiver1.google.com comp.lang.ada:42655 Date: 2003-09-18T08:28:15+00:00 List-Id: >>>>> "JSA" == Jacob Sparre Andersen writes: JSA> Olehjalmar Kristensen wrote: >>>>>>> "RIE" == Robert I Eachus writes: RIE> interfaces and mix-ins. But type inheritance cannot be from two RIE> concrete parents, no matter what the language--one parent has to be RIE> abstract. So anyone who condemns Ada for not adding what cannot be RIE> done needs to get a life. >> What do you mean by "concrete parents"? JSA> Although I agree that "non-abstract parents" is the most obvious JSA> interpretation of "concrete parents", I understood it as JSA> "data-containing non-abstract parents". I understand now, by see below. >> class a { >> public: >> void foo(); >> }; >> class b { >> public: >> void bar(); >> }; >> class c: public a, public b{ >> }; >> Works just fine, JSA> Looks that way to me too. But if a and b had contained data, for JSA> example position data in respectively spherical and rectangular JSA> coordinates (to reuse an earlier example), then you would most likely JSA> end up in trouble. JSA> Jacob JSA> -- JSA> Rent-a-Minion Inc. Because good help is so hard to find. Depends on what you expect. As you can see, there is no conflict as such. On the other hand, a and b can not access each others variables either. In the general case I agree, there may be problems, but I think that the compiler rejecting cases it cannot resolve properly is quite acceptable. file multi.cc: #include class a { public: int x; a() : x(13) {} void foo(){printf("%p %d\n",&x,x);}; }; class b { public: int x; b() : x(666) {} void bar(){printf("%p %d\n",&x,x);}; }; class c : public a, public b { }; main() { c cc; cc.foo(); cc.bar(); } ok145024@khepri06:~/div> ./multi 8046abc 13 8046ac0 666 To let the two classes use each others functions and data you can do the following: file multi2.cc: #include class base { public: virtual int x1() = 0; virtual int x2() = 0; }; class a : public virtual base { public: int x; a() : x(13) {} int x1() {return x;} void foo(){printf("%p %d %d\n",&x,x,x2());}; }; class b : public virtual base { public: int x; b() : x(666) {} int x2() {return x;} void bar(){printf("%p %d %d\n",&x,x,x1());}; }; class c : public a, public b { }; main() { c cc; cc.foo(); cc.bar(); } ok145024@khepri06:~/div> ./multi2 8046ab4 13 666 8046abc 666 13 -- This page intentionally left blank