In our application there is general used classes( e.g a class which holds project configuration parameters ) like below .
class DB{
public:
int projectVersion
int somethingSoMuchImportantAllOverTheProject
};
extern DB* pDB;
Because all other classes will use this class, all of them needs to access it somehow . Our solution is putting "extern DB* pDB;" under its header file so whoever needs it, will be able to access it after including the header . I am thinking maybe there is a better solution and want to get your ideas for this general case.
It's a singleton. You can find lots of discussions on it, but one important thing is, hide the constructor of the class so users of the class are forced to use the one object.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With