Does one have any tangible benefits over the other? I've started using the latter because it doesn't pollute the header file with static const declarations, so it's a bit easier to read. I'm often using these constants in only a couple of member functions.
Class scope:
.hpp
class MyType
{
private:
static const std::wstring kFoo;
}
.cpp
const wstring MyType::kFoo(L"foo");
...
void MyType::parse(const wstring& input)
{
if (input == kFoo) { do1; }
...
}
versus
namespace scope
.cpp
const wstring kFoo(L"foo");
...
void MyType::parse(const wstring& input)
{
if (input == kFoo) { do1; }
...
}