lundi 13 juin 2016

C++ Using (communications) object in every other class

I've recently made an "communications" object/abstract class, on which I can use the functions: "send", "receive", "debugsend" etc.

Now, I'd like to use this object in basically every other class, so that I can use it to send debug messages.

At the moment I'll have to do:

#include "../communication/ICommunication.hpp"
extern Communication* comm;

In any of the other files/classes where I want to use this object. While this seems to work very well, I was wondering if there is a neater way to do this.

I believe there is an software pattern for this, though I can't remember the name, nor the implementation. The name of the pattern was, I believe, a persons last name.

I'd like to know the name of this pattern (or any pattern that's good for this purpose), so I could try the implementation myself. If possible, also some arguments on why that pattern is better than the "include and extern" code.

Aucun commentaire:

Enregistrer un commentaire