Singleton with two getInstance() methods handing over a parent pointer?
问题 I am still working on my Logger and I like the idea of a Singleton but my Logger derives frm QDialog, thus I would like to handle my Parent QWidget* MainWindow pointer when I call it first: class Logger : public QDialog { Q_OBJECT private: explicit Logger(QWidget* parent = 0); public: static Logger& firstInstance(QWidget* parent = 0) { static Logger theInstance(parent); return theInstance; } static Logger& instance() { return theInstance; } //.. } So I would call Logger::firstInstance(this);