Created
July 20, 2016 21:09
-
-
Save zainulabidin302/8f33d637eb0647c92aecad185b0c3df1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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