I have done C# and C, but still, when I come to this C++ project, I am a little stucked for this little code style problem.
I have a couple of const variables(might be strings or numbers) in a C++ program, and I want to gather them in one place and access them from other classes.
For example, in C# and java, we can have a resource file or a config file to store all those data, or maybe just a singleton or static class.
But what is the best way I should do it with C++? should I put the const variables in a header file or make a class like JAVA?
IMO this is one of the shortcoming of C# and Java – everything has to be inside a class.
In C++ you have
twothree options:If your constants are logically related to a class, put them in the class. Otherwise, use a
namespace.