C++ Cyclic Dependency Design -



C++ Cyclic Dependency Design -

been using solutions while... first question asked. (not sure if proper venue). stuck design problem.

i have 3 classes, user, strategy, & communicator.

i user have pointer communicator, , phone call functions when necessary.

i user have list of class strategy, , phone call functions of strategy when necessary.

i communicator have list of class strategy, , pointer user, , phone call functions on when necessary.

if helps, communicator simply wrapper around socket connection listens messages client , sends them user or strategy, whichever appropriate. contains function send(string message) sends messages user & strategy client.

the problem cannot compile, since header files end including each other. ideas appreciated!

forward declarations friends.

strategy.h:

class user; class communicator; class strategy { /* definition of strategy, restricted utilize of user , communicator */ };

strategy.cpp:

#include "strategy.h" #include "user.h" #include "communicator.h" /* total utilize of 3 classes */

c++ circular-dependency

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -