dca_interface
6.3.4
|
The use of global variables is not recommended.
A preferred solution would be to create variables in your main() (or similar) function and to pass them via reference to other functions as required.
This ensures that once the DoWork() function returns, the DcaInstance goes out of scope, and all variables are destructed in the reverse creation order.
The object instances can be placed in a separate function as well as the deinit code.
For more information on this please refer to Startup/Shutdown sequence.
If you're using many more variables than in our example, you may also use a so called context:
So it's very easy to add more global-like variables to your context and create them in the scope of your main() function.
Since the assignment operators of all classes have been overloaded, you will not need to deal with checks for visibility, where to destruct variables or even where to addref or release an object.
This is all done automatically by the wrapper layer of the SCA API.