class error_category { protected: error_category() = default; public: virtual const char* name() const = 0; }; const error_category& get_category(); static const error_category& category = get_category(); class error_code { public: error_code() : _c(&category) { } const error_category& cat() const { return *_c; } private: const error_category* _c; };