Hello,
I am tryign to use the Singleton design patterno on Linux, but it is not working:
in the .h I have:
in the .cpp I have:Code:public: static ErrorH& Instance(); private: ErrorH() {};
The errors I get are:Code:ErrorH& ErrorH::Instance() { static ErrorH& self = ErrorH(); return self; }
This code works on Windows, how can I get it to work on Linux?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
Regards.


Reply With Quote
Bookmarks