c++ - Function pointer to singleton class instance function -
what i'm trying create function pointer single class instance function. want can this:
c->member_method();
instead of:
config::inst()->member_method();
but i'm not sure how go it. here singleton class:
class config { private: config() {} static config* m_instance; public: ~config() {} static config* inst() { if (m_instance == nullptr) { m_instance = new config; } return m_instance; } bool load(); };
thanks in advance
simply create normal class without static methods, ditch singleton pattern aside, , create instance.
the burden of singleton pattern usually outweigh benefit.
Comments
Post a Comment