When implementing the Singleton pattern the compiler gives the following error:
include \ graphdata.h | 21 | error: 'constexpr' needed for in-class initialization of static data member 'graphdata * graphdata :: instance' of non-integral type [-fpermissive] |
The code I made is as follows:
class graphdata
{
public:
static graphdata& getinstance(){
if(!instance)
instance = new graphdata();
return *instance;
}
void dfsR();
graphdata(graphdata const&) = delete;
void operator = (graphdata const&) = delete;
protected:
private:
graphdata();
static graphdata* instance = 0;
};