title: c++ best way to realise global switches/flags to control program behaviour without tying the classes to a common point
body: <p>Let me elaborate on the title:</p>
  
  <p>I want to implement a system that would allow me to enable/disable/modify the general behavior of my program. Here are some examples:</p>
  
  <ul>
  <li>I could switch off and on logging</li>
  <li>I could change if my graphing program should use floating or pixel coordinates</li>
  <li>I could change if my calculations should be based upon some method or some other method</li>
  <li>I could enable/disable certain aspects like maybe a extension api</li>
  <li>I could enable/disable some basic integrated profiler (if I had one)</li>
  </ul>
  
  <p>These are some made-up examples. </p>
  
  <p>Now I want to know what the most common solution for this sort of thing is.</p>
  
  <p>I could imagine this working with some sort of singelton class that gets instanced globally or in some other globally available object. Another thing that would be possible would be just constexpr or other variables floating around in a namespace, again globally.</p>
  
  <p>However doing something like that, globally, feels like bad practise.</p>
  
  <p><strong>second part of the question</strong></p>
  
  <p>This might sound like I cant decide what I want, but I want a way to modify all these switches/flags or whatever they are actually called in a single location, without tying any of my classes to it. I don't know if this is possible however. </p>
  
  <p>Why don't I want to do that? Well I like to make my classes somewhat reusable and I don't like tying classes together, unless its required by the DRY principle and or inheritance. I basically couldn't get rid of the flags without modifying the possible hundreds of classes that used them.</p>
  
  <p><strong>What I have tried in the past</strong></p>
  
  <ul>
  <li>Having it all as compiler defines. This worked reasonably well, however I didnt like that I couldnt make it so if the flag file was gone there were some sort of default settings that would make the classes themselves still operational and changeable (through these default values)</li>
  <li>Having it as a class and instancing it globally (system class). Worked ok, however I didnt like instancing anything globally. Also same problem as above</li>
  <li>Instancing the system class locally and passing it to the classes on construction. This was kinda cool, since I could make multiple instruction sets. However at the same time that kinda ruined the point since it would lead to things that needed to have one flag set the same to have them set differently and therefore failing to properly work together. Also passing it on every construction was a pain.</li>
  <li>A static class. This one worked ok for the longest time, however there is still the problem when there are missing dependencies.</li>
  </ul>
  
  <p><strong>Summary</strong></p>
  
  <p>Basically I am looking for a way to have a single "place" where I can mess with some values (bools, floats etc.) and that will change the behaviour of all classes using them for whatever, where said values either overwrite default values or get replaced by default values if said "place" isnt defined.</p>