Answers for "undefined reference to instance"

C++
1

undefined reference to instance

//Put this in the .cpp
Singleton *Singleton::instance = NULL;

//! This is the Singleton definition in .hpp
class Singleton {
private:
  static Singleton *instance;
  
public:
  static Singleton *getInstance() {
    if (instance == NULL) {instance = new Singleton; }
    return instance;
  }

protected:
  Singleton() { std::cout << "singleton created\n"; };
};
Posted by: Guest on November-23-2020

Code answers related to "undefined reference to instance"

Browse Popular Code Answers by Language