Skip to content

Instantly share code, notes, and snippets.

@zainulabidin302
Created July 20, 2016 21:09
Show Gist options
  • Save zainulabidin302/8f33d637eb0647c92aecad185b0c3df1 to your computer and use it in GitHub Desktop.
Save zainulabidin302/8f33d637eb0647c92aecad185b0c3df1 to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
class ConfigurationManager {
private:
ConfigurationManager(){
}
public:
static ConfigurationManager & getInstance() {
static ConfigurationManager cm; // automatically destroyed
// instantiated when needed
return cm;
}
void configure() {
cout << "Configuration successfull" << endl ;
}
};
int main () {
ConfigurationManager cm = ConfigurationManager::getInstance();
cm.configure();
//ConfigurationManager cm2 = new ConfigurationManager(); You cant do this, because constructor is private.
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment