I have a class with a container that is declared static:
class test { public: test(const ClassA& aRef, const std::string& token); test(const test& src); ~test(); private: ClassA& m_ObjRef; static std::vector<std::string> s_toks; };
The s_toks container is initialized as follows in the constructor defined in test.cpp:
std::vector<std::string> test::s_toks; test::test(const ClassA& aRef, const std::string& token) : m_ObjRef(aRef) { my_tokenize_function(token, s_toks); } test::test(const test& src) : m_ObjRef(src.m_ObjRef) { }
If I do not copy s_toks, and s_toks is accessible from the newly copied object, it is empty. What is the right way to handle this?
source share