I have a C++ application (C++11) and deep in the call hierarchy I have a function that I would like to be able to show output from in occasional circumstances. The question is how to tell the function whether or not to show the output. It seems like the options are:
- Pass in some variable through the call hierarchy, or add a value to the parameter object already being passed through the hierarchy
- Set a global variable that the function checks.
- Read in a parameter from a file
- If we can set it at compile time, use a #ifdef that includes the code
None of these feels right, so I'm looking for a design pattern or discussion of the right way to do this.
Aucun commentaire:
Enregistrer un commentaire