000
29.10.2015, 11:40 Uhr
Ginso
|
Hallo, ich möchte ein Singleton prommarien. Hier ist mein Code:
Header:
Code: |
#pragma once #include <stdio.h>
class MLog { public: MLog(void); ~MLog(void); static MLog* getInstance(); FILE* file; template <typename ... Ts> void writef(const char* format, Ts ... ts) { fprintf(file,format,ts...); }
/*template <typename ... Ts> static void write(const char* format,Ts ... ts) { getInstance()->writef(format, ts...); }*/ protected: static MLog* s_instance; };
|
source:
Code: |
#include "MLog.h"
MLog::MLog(void) { file = fopen("D:\\Temp\\log.txt","W"); }
MLog::~MLog(void) { fclose(file); }
MLog* MLog::getInstance() { if(!s_instance) s_instance = new MLog(); return s_instance; }
|
Beim Erstellen erhalte ich folgenden Fehler:
error LNK2001: Nicht aufgelöstes externes Symbol ""protected: static class MLog * MLog::s_instance" (?s_instance@MLog@@1PAV1@A)". |