undefined reference to instance

Solutions on MaxInterview for undefined reference to instance by the best coders in the world

showing results for - "undefined reference to instance"
Giuseppe
05 Jan 2019
1//Put this in the .cpp
2Singleton *Singleton::instance = NULL;
3
4//! This is the Singleton definition in .hpp
5class Singleton {
6private:
7  static Singleton *instance;
8  
9public:
10  static Singleton *getInstance() {
11    if (instance == NULL) {instance = new Singleton; }
12    return instance;
13  }
14
15protected:
16  Singleton() { std::cout << "singleton created\n"; };
17};
18