Skip to content

Instantly share code, notes, and snippets.

@anddam
Last active November 29, 2021 20:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anddam/5bb3b322f74a13ff8d809ba01f745a63 to your computer and use it in GitHub Desktop.
Save anddam/5bb3b322f74a13ff8d809ba01f745a63 to your computer and use it in GitHub Desktop.
C++ logger class excerpt
Logger * Logger::m_Instance = 0;
Logger::Logger() {
char* buf = nullptr;
size_t sz = 0, l = 0;
// No `m_Instance` declared here
Logger * Logger::getInstance() throw () {
if (m_Instance == 0) {
m_Instance = new Logger();
}
return m_Instance;
}
}
class Logger {
public:
static Logger * getInstance() throw ();
private:
static Logger * m_Instance;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment