home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / cplus / 19770 < prev    next >
Encoding:
Text File  |  1993-01-23  |  3.4 KB  |  101 lines

  1. Path: sparky!uunet!pipex!doc.ic.ac.uk!uknet!axion!gssec.bt.co.uk!mjackson
  2. From: mjackson@gssec.bt.co.uk (Mark Jackson)
  3. Newsgroups: comp.lang.c++
  4. Subject: Mixins (was Re: C++ Multiple inheritance)
  5. Keywords: multiple inheritance
  6. Message-ID: <1993Jan22.141845.23138@gssec.bt.co.uk>
  7. Date: 22 Jan 93 14:18:45 GMT
  8. 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>
  9. Sender: usenet@gssec.bt.co.uk
  10. Organization: BT, Software Engineering Centre, Glasgow, Scotland
  11. Lines: 88
  12.  
  13. In article <1993Jan21.011328.4841@ucc.su.OZ.AU>, maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
  14. |> In article <1993Jan20.135930.14615@gssec.bt.co.uk> mjackson@gssec.bt.co.uk (Mark Jackson) writes:
  15. |> >In reply to Dennis Marer and SR Heintz (sorry, my email doesn't
  16. |> >recognise your mail address), I think I have a 'real world' example
  17. |> >for you...
  18. |> >
  19. |> >The system is Client-Server based, communicating via common IPC
  20. |> >service classes.
  21. |> >
  22. |> >class IPCEventHandler : public IPCClient, public EventHandler
  23. |> >{
  24. |> >  public:
  25. |> >    ......
  26. |> >    // Virtual method Inherited from EventHandler
  27. |> >    void HandleEvent( Event& theEvent )
  28. |> >    {
  29. |> >        // Build an IPC Message from the Event data
  30. |> >        IPCMessage theMessage( theEvent.getData() );
  31. |> >
  32. |> >        // Send the resulting message over the IPC
  33. |> >        // using method inherited from IPCClient
  34. |> >        SendMessage( theMessage );
  35. |> >    }
  36. |> >    ......
  37. |> >};
  38. |> >
  39. |> >Unfortunately, at this point, I was supposed to come up with the reason why
  40. |> >I couldn't just inherit from the EventHandler class, and have the IPCClient
  41. |> >as a data member, but try as I might, I can't remember....................
  42. |> 
  43. |>     I'll remind you: you override a method from Event handler,
  44. |> thus you cant have it as a member.
  45.  
  46. BULL, as you say below. If you'd read what I wrote, you'd see
  47. I'm talking about having an IPC object as a member,
  48. NOT the EventHandler. This would look like
  49.  
  50. class IPCEventHandler : public EventHandler
  51. {
  52.   private:
  53.     IPCClient *ipc;
  54.  
  55.   public:
  56.     ......
  57.     // Virtual method Inherited from EventHandler
  58.     void HandleEvent( Event& theEvent )
  59.     {
  60.         // Build an IPC Message from the Event data
  61.         IPCMessage theMessage( theEvent.getData() );
  62.  
  63.         // Send the resulting message over the IPC
  64.         // using IPCClient object
  65.         ipc->SendMessage( theMessage );
  66.     }
  67.     ......
  68. };
  69.  
  70. Still can't remember why I couldn't do this, though, which is really beginning
  71. to bug me #$^@!&
  72.  
  73. |> 
  74. |> >P.S. I still think using MI with more than 2 parent classes is decidedly
  75. |> >dodgy. 4 is right out. (Book of Armaments: Ch. 4 v. 5) 
  76. |> >
  77. |>     Bull. Use as many as is appropriate.
  78. |>     With mixins, that could be quite a few.
  79.  
  80. I've seen you championing mixins in other articles. Could you give
  81. us a few wee, but not Noddy, examples.
  82. Then you may be able to twist my arm...
  83.  
  84. |> 
  85. |> 
  86. |> -- 
  87. |> ;----------------------------------------------------------------------
  88. |>         JOHN (MAX) SKALLER,         maxtal@extro.ucc.su.oz.au
  89. |>     Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
  90. |> ;------ SCIENTIFIC AND ENGINEERING SOFTWARE ---ph:  2 799 8223 --------
  91.  
  92. -- 
  93.  
  94.    !!!!!!!     __________________________
  95.    +(.)(.)    (                          )
  96.    C   > )    |  I, and only I, said it. |
  97.     \ V / ----(__________________________)
  98.      ---
  99.  
  100. Mark Jackson
  101.