I'm trying to make sure that a module only loads exactly once but when I do it my way, the compiler spits out "Undefined reference to both my static class variables :S
class Text : public Parent { private: static int Instances; static HMODULE Module; public: Text(); Text(Text&& T); Text(std::wstring T); ~Text(); virtual Text& operator = (Text&& T); }; Text::Text() : Parent() {} Text::~Text() { if (--Instances == 0) FreeLibrary(Module); // Only free the module when // no longer in use by any instances. } Text::Text(Text&& T) : Parent(std::move(T)), Module(std::move(T.Module)) Text::Text(std::wstring T) : Parent(T) // Module only loads when // this constructor is called. { if (++Instances == 1) { Module = LoadLibrary(_T("Msftedit.dll")); } } Text& Text::operator = (Text&& T) { Parent::operator = (std::move(T)); std::swap(T.Module, this->Module); return *this; } Any ideas why it says undefined reference to BOTH variables (Instances & Module)?