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

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -