1

I'm trying to write a singleton in c++ - but I got LNK2019 error:

Severity Code Description Project File Line Error LNK2019 unresolved external symbol "private: __thiscall DBWriter::DBWriter(void)" (??0DBWriter@@AAE@XZ) referenced in function "public: static class DBWriter * __cdecl DBWriter::getInstance(void)" (?getInstance@DBWriter@@SAPAV1@XZ) ORCompare

Can someone help me find my mistake?

Here is the h. file:

#pragma once
#ifndef DBWRITER
#define DBWRITER

 class DBWriter
{

public:

    ~DBWriter();
    static DBWriter* getInstance();

private:
    DBWriter();

    static DBWriter *dbwriter;
};

#endif //DBWRITER

and the .cpp file:

#include "DBWriter.h"

DBWriter * DBWriter::getInstance()
{
    if (dbwriter == NULL)
        dbwriter = new DBWriter();
    return dbwriter;
}

I'll be happy if someone can explain me my mistake. Thank you.

STF
  • 1,485
  • 3
  • 19
  • 36

0 Answers0