2
When implementing the Singleton standard 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 this::
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;
};
I even tried, but got the error saying *instance is private.
– Diego Rangel
That’s another mistake, I showed you how to fix this mistake. But I suggest you start doing simpler things first. You are skating on basic points that you must learn before trying to do something more complex.
– Maniero