I have the following classes, Base and Derived and when I compile the compiler complains that it cannot create an instance of DLog because it is abstract.
Can someone tell me how I can fix this error?
I'm guessing it's because not both pure virtual functions are not implemented in the Derived.
class Logger
{
public:
virtual void log(int debugLevel, char* fmt, ...) = 0;
virtual void log(string logText, int debugLevel, string threadName = "") = 0;
static Logger* defaultLogger() {return m_defaultLogger;}
static void setDefaultLogger(Logger& logger) {m_defaultLogger = &logger;}
protected:
static Logger* m_defaultLogger;
};
class DLog : public Logger
{
public:
DLog();
~DLog();
static DLog *Instance();
static void Destroy();
void SetLogFilename(std::string filename);
void SetOutputDebug(bool enable);
std::string getKeyTypeName(long lKeyType);
std::string getScopeTypeName(long lScopeType);
std::string getMethodName(long lMethod);
virtual void log(string logText, int debugLevel)
{
Log(const_cast<char*>(logText.c_str()));
}
void Log(char* fmt, ...);
private:
static DLog *m_instance;
std::string m_filename;
bool m_bOutputDebug;
};
// DLog instantion as a singleton
DLog *DLog::Instance()
{
if (!m_instance)
m_instance = new DLog();
return m_instance;
}