home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!pipex!doc.ic.ac.uk!uknet!axion!gssec.bt.co.uk!mjackson
- From: mjackson@gssec.bt.co.uk (Mark Jackson)
- Newsgroups: comp.lang.c++
- Subject: Mixins (was Re: C++ Multiple inheritance)
- Keywords: multiple inheritance
- Message-ID: <1993Jan22.141845.23138@gssec.bt.co.uk>
- Date: 22 Jan 93 14:18:45 GMT
- References: <1993Jan16.062140.18874@microsoft.com> <C12AxH.CKr@inews.Intel.COM> <1993Jan20.135930.14615@gssec.bt.co.uk> <1993Jan21.011328.4841@ucc.su.OZ.AU>
- Sender: usenet@gssec.bt.co.uk
- Organization: BT, Software Engineering Centre, Glasgow, Scotland
- Lines: 88
-
- In article <1993Jan21.011328.4841@ucc.su.OZ.AU>, maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
- |> In article <1993Jan20.135930.14615@gssec.bt.co.uk> mjackson@gssec.bt.co.uk (Mark Jackson) writes:
- |> >In reply to Dennis Marer and SR Heintz (sorry, my email doesn't
- |> >recognise your mail address), I think I have a 'real world' example
- |> >for you...
- |> >
- |> >The system is Client-Server based, communicating via common IPC
- |> >service classes.
- |> >
- |> >class IPCEventHandler : public IPCClient, public EventHandler
- |> >{
- |> > public:
- |> > ......
- |> > // Virtual method Inherited from EventHandler
- |> > void HandleEvent( Event& theEvent )
- |> > {
- |> > // Build an IPC Message from the Event data
- |> > IPCMessage theMessage( theEvent.getData() );
- |> >
- |> > // Send the resulting message over the IPC
- |> > // using method inherited from IPCClient
- |> > SendMessage( theMessage );
- |> > }
- |> > ......
- |> >};
- |> >
- |> >Unfortunately, at this point, I was supposed to come up with the reason why
- |> >I couldn't just inherit from the EventHandler class, and have the IPCClient
- |> >as a data member, but try as I might, I can't remember....................
- |>
- |> I'll remind you: you override a method from Event handler,
- |> thus you cant have it as a member.
-
- BULL, as you say below. If you'd read what I wrote, you'd see
- I'm talking about having an IPC object as a member,
- NOT the EventHandler. This would look like
-
- class IPCEventHandler : public EventHandler
- {
- private:
- IPCClient *ipc;
-
- public:
- ......
- // Virtual method Inherited from EventHandler
- void HandleEvent( Event& theEvent )
- {
- // Build an IPC Message from the Event data
- IPCMessage theMessage( theEvent.getData() );
-
- // Send the resulting message over the IPC
- // using IPCClient object
- ipc->SendMessage( theMessage );
- }
- ......
- };
-
- Still can't remember why I couldn't do this, though, which is really beginning
- to bug me #$^@!&
-
- |>
- |> >P.S. I still think using MI with more than 2 parent classes is decidedly
- |> >dodgy. 4 is right out. (Book of Armaments: Ch. 4 v. 5)
- |> >
- |> Bull. Use as many as is appropriate.
- |> With mixins, that could be quite a few.
-
- I've seen you championing mixins in other articles. Could you give
- us a few wee, but not Noddy, examples.
- Then you may be able to twist my arm...
-
- |>
- |>
- |> --
- |> ;----------------------------------------------------------------------
- |> 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 --------
-
- --
-
- !!!!!!! __________________________
- +(.)(.) ( )
- C > ) | I, and only I, said it. |
- \ V / ----(__________________________)
- ---
-
- Mark Jackson
-