I have some static const strings as private members of my C++ class. I am aware of the declaration in .h and definition (and initialization) in .cpp practice. In the class c
I'd use a different approach:
class Test
{
public:
Test() : m_data( "Data" ) {}
private:
const std::string m_data;
};
I personally prefer this 'style' and it would remove any issues with having initialised data in the constructor at what is likely to be the minor cost of constructing the string for each instance.