static Logger getLogger() { return log; }
tries to return a Logger value by a value that requires a copy constructor. The creator created by the compiler is trying to make a copy of the debug element. That is why you get an error.
You can either implement the copy constructor (it may not make sense, since the debug member will be different) or return by reference:
static Logger& getLogger() { return log; }
which is safe in this case, because log has a static storage duration .
The correct call would look like this:
Logger& l = Logger::getLogger();
in this case, l refers to Logger::log .
source share