Where to declare/define class scope constants in C++?
问题 I'm curious about the benefits/detriments of different constant declaration and definition options in C++. For the longest time, I've just been declaring them at the top of the header file before the class definition: //.h const int MyConst = 10; const string MyStrConst = "String"; class MyClass { ... }; While this pollutes the global namespace (which I know is a bad thing, but have never found a laundry list of reasons why it is bad), the constants will still be scoped to individual