There are too many different answers on stack overflow:
Declare a namespace, and in the hpp file mark all strings as extern const, and in the cpp file put their definitions.
C++ How to share constants with extern between cpp - Error: storage class specified
Use static const instead of extern const:
Use an inline function :
static string constants in class vs namespace for constants [c++]
Use anonymous namespaces!
Where do I put constant strings in C++: static class members or anonymous namespaces?
This is all really confusing. Using an inline function seems like a really lengthy and tedious way to return a string constant.
Why can't we just use namespaces containing static strings, which are defined in the cpp file ?
Can someone please provide an categorical / unequivocal answer of how one should store strings in a constant file, so multiple cpp files can access them ?
EDIT: In C# and Java it seems to be a non-issue to store all your constants in a "Constants" file. What is the easiest way to do this in C++ ?
EDIT: These answers in Java seem specific and understandable. In C++ it is unclear which is the way likely to have least compilation time, least memory usage at run time.
Sharing constant strings in Java across many classes?
https://dzone.com/articles/constants-in-java-the-anti-pattern-1