title: What is the best strategy for sharing variables between source files in c/c++?
body: <p>I frequently have to write c/c++ programs with 10+ source files where a handful of variables need to be shared between functions in all the files. I have read before that it is generally good practice to avoid using global variables with <code>extern</code>. However, if it is completely necessary to use global variables, this <a href="https://stackoverflow.com/questions/1433204/what-are-extern-variables-in-c">link</a> provides a good strategy. Lately, I have been toying with the strategy of wrapping up all my variables in a struct or a class and passing this struct around to different functions. I was wondering which way people consider to be cleaner and if there are any better alternatives.</p>
  
  <p>EDIT: I realize strategies may be different in the two languages. I am interested in strategies that apply to only one language or both.</p>