I\'m writing C++ code on a mac. Why do I get this error when compiling?:
Undefined symbols for architecture i386: \"Log::theString\", referenced f
In C++17, there is an easier solution using inline
variables:
class Log{
public:
static void method(string arg);
private:
inline static string theString;
};
This is a definition, not just a declaration and similar to inline
functions, multiple identical definitions in different translation units do not violate ODR. There is no longer any need to pick a favourite .cpp file for the definition.