In a multi-threaded C ++ application with many classes, I'm trying to figure out which methods define a global variable
C, define it as global in any source file, define it as extern in the header, which is included in the classes that access this variable.
Write a Singleton class that contains these global variables and provides set / get methods for writing to a variable.
In the second method, you can manage multi-threaded access through locks in a centralized manner, rather than the first approach.
Are there any better ways?
Sashi source
share