|
|||
|
In a Client Server setup execution flow is often akin to:
a) Read Client Data -> b) Process -> c) Write Server Data d) Read Server Data -> e) Update -> f) Write Client Data On the Client side, I'm faced with two classes. class Base_Message { virtual ~Base_Message() {} }; class CMsg1 : public Base_Message {}; //CMsg: from Client class SMsg1 : public Base_Message {}; //SMsg: to Client class Handle_Incoming : public Base_Handler { CMsg1 Client_Msg ; public: void Process () { /* work */ } }; class Handle_Outgoing : public Base_Handler { SMsg1 Server_Msg ; public: void Update ( /*...*/ ) { /*update Server_Msg* pre f) above */ } }; Incoming client messages are local to the Handle_Incoming class. Outgoing server data is local to the Handle_Outgoing. The outgoing server msg (SMsg1) needs to be shared between the Handle_Incoming and Handle_Outgoing classes. I can hear you saying, "Make a base class and derive from it!", and yes, I could do that. In fact I did that as a temporary measure, but this defines a relationship between the Handle_Incoming and Handle_Outgoing classes that doesn't exist. In my view using an interface will not help in this situation, because it doesn't offer implementation sharing. Inheritance offers a relationship with implementation sharing, an interface offers a relationship without implementation sharing, but I want implementation sharing without the relationship. My question becomes: How do I make SMsg1 available for both Handle_Incoming and Handle_Outgoing classes when a relationship among them doesn't exist? Thanks in advance. -- [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ] |
|
|
||||
|
||||
|
|
![]() |
| Popular Tags in the Forum |
| classes, code, common, unrelated |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Seeking computer-programming job (Sunnyvale, CA) | Robert Maas | Newsgroup comp.lang.lisp | 1631 | 07-14-2009 04:04 AM |
| sending sms from j2me program | focode | Newsgroup comp.lang.java.programmer | 2 | 07-05-2009 09:37 PM |
| Intel fortran compiler 11 on AMD opteron | sambarluc | Newsgroup comp.lang.fortran | 7 | 06-10-2009 10:24 AM |
| Program Fails When Parameter Fixed Constants are Changed (F77) ?? | monir | Newsgroup comp.lang.fortran | 104 | 04-22-2009 09:14 PM |
| Re: How can one eliminate Error statement in the following code? | Ian Whitlock | Newsgroup comp.soft-sys.sas | 0 | 01-19-2007 08:27 PM |