C++ Global data structures
-
Hi, I'm currently working on a singel project witch includes many threads. There will be one class which implements the input and output. Next to that, there will be a single object (GLOBAL!) which stores information. more specific, both the IO class and the threads will communicate with the global storage object, so where to declare it? The application is fully written in C++ and totally OO Thanks already! Koen B
-
Hi, I'm currently working on a singel project witch includes many threads. There will be one class which implements the input and output. Next to that, there will be a single object (GLOBAL!) which stores information. more specific, both the IO class and the threads will communicate with the global storage object, so where to declare it? The application is fully written in C++ and totally OO Thanks already! Koen B
-
In your case, implement the global data object as a Singleton class. Whenever you want to use the object, call the specific static method to get its instance. It does not matter where you declare it first.
Best, Jun