jeudi 14 janvier 2021

Defining a block of scoped global variables in C++

I am writing code where I need a block of globals, say, Param that is accessible to all the other header *.hpp/.h and the *.cpp files. Theses globals need to be initialized in the beginning and can be changed throughout the code run. There also needs to be a single instance of the block and all contents are shared. All the contents need to be global.

What is the best possible way to implement it? A namespace Param{}; or a class Param{};- with all the members declared static?

Also, how would we make some constants in the block thread_local (best practice)?

Aucun commentaire:

Enregistrer un commentaire