Hello,
I am tryign to use the Singleton design patterno on Linux, but it is not working:
in the .h I have:
Code:
public:
static ErrorH& Instance();
private:
ErrorH() {};
in the .cpp I have:
Code:
ErrorH& ErrorH::Instance()
{
static ErrorH& self = ErrorH();
return self;
}
The errors I get are:
Code:
g++ --g -c ErrorH.cpp -o ErrorH.o
ErrorH.cpp: In static member function ‘static ErrorH& ErrorH::Instance()’:
ErrorH.cpp:9: error: invalid initialization of non-const reference of type ‘ErrorH&’ from a temporary of type ‘ErrorH’
make: *** [ErrorH.o] Error 1
This code works on Windows, how can I get it to work on Linux?
Regards.