If you have a class that has some named constants, what is the best practive for storing the constants:
Option 1: Namespace in Class header
So in my class header I will have:
class myClass
{
...
...
};
namespace NamedConstants
{
const string Bucket = "Bucket";
}
Option 2 Member Constants
class MyClass { // this goes in the class
private: // header file
static const string Bucket;
...
};
// this goes in the class implementation file
const string MyClass::Bucket = "Bucket";
I actually prefer Option 1 as it is cleaner as variable name and value are together. Also, if you give the namespace a good name then it can make code more readable when you use constants:
TrafficLight::Green
Does anybody see any issue with this method over option 2?