home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!seismo!darwin.sura.net!paladin.american.edu!howland.reston.ans.net!spool.mu.edu!sgiblab!munnari.oz.au!metro!extro.ucc.su.OZ.AU!maxtal
- From: maxtal@extro.ucc.su.OZ.AU (John MAX Skaller)
- Newsgroups: comp.lang.c++
- Subject: Re: Mixins
- Message-ID: <1993Jan26.222925.8025@ucc.su.OZ.AU>
- Date: 26 Jan 93 22:29:25 GMT
- References: <24656@alice.att.com> <1993Jan21.005415.2812@ucc.su.OZ.AU> <1993Jan22.121031.11305@actrix.gen.nz>
- Sender: news@ucc.su.OZ.AU
- Organization: MAXTAL P/L C/- University Computing Centre, Sydney
- Lines: 58
- Nntp-Posting-Host: extro.ucc.su.oz.au
-
- In article <1993Jan22.121031.11305@actrix.gen.nz> chris@actrix.gen.nz (Chris Double) writes:
- >In article <1993Jan21.005415.2812@ucc.su.OZ.AU> maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
- >>
- >> But your greatest achievement, Bjarne, in my opinion,
- >> was the name dominance rule, because, coupled with virtual
- >> bases and abstract classes that enables mixins.
- >>
- >
- >Hi.
- >
- >I've read a lot on this newsgroup about how good mixins are but how
- >some compilers don't support them.
- >
- >I've never come across this term before. Would somebody be able to
- >explain what the 'mixin' concept is?
-
- Sort of 'tailor made classes'. Brew em up as you need
- them. Sorry-I'll have to prepare a standard answer to this.
- A moderate sized demo is in the works.
-
- >
- >Also what is wrong with the compilers that don't support it. I
- >understand Borland doesn't. So what isn't borland doing that it
- >should?
- >
-
- // RE Abstract Classes
- // some compilers work and others fail when #define KLUDGE is
- // commented out. Some say D is abstract.
- // CLEARLY it is not.
- // However rewiting rules in ARM are not clear.
- // It is essential for "mix-in" programming that D is concrete.
- //
- #define KLUDGE
- #ifndef KLUDGE
- class V {public: virtual void f()=0; virtual void g()=0;};
- #else
- class V {public: virtual void f(){printf("ERROR V::g\n");}
- virtual void g(){printf("ERROR V::g\n");}};
- #endif
- class A1 : public virtual V {public: void f(){printf("A1::f\n");}};
- class A2 : public virtual V {public: void g(){printf("A2::g\n");}};
- class D : public A1, public A2 {};
- int main()
- {
- D* d=new D;
- A1 * a1=d;
- A2 * a2=d;
- V * v = d;
- d->f(); a1->f(); a2->f(); v->f();
- d->g(); a1->g(); a2->g(); v->g();
- }
-
- --
- ;----------------------------------------------------------------------
- JOHN (MAX) SKALLER, maxtal@extro.ucc.su.oz.au
- Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
- ;------ SCIENTIFIC AND ENGINEERING SOFTWARE ---ph: 2 799 8223 --------
-