I have been writing this class for logging but I haven't been fixing this problem.
mylogger.cpp
#include "../inc/mylogger.h"
MyLogger::MyLogger()
{
cout << "hi" << endl;
}
template<typename... Args>
void MyLogger::function1(Args... args)
{
printf( args...);
}
MyLogger MYLOGGER = MyLogger();
mylogger.h
#ifndef MYLOGGER_H
#define MYLOGGER_H
#include <iostream>
#include <iostream>
#include <cstdarg>
#include <string>
#include <thread>
#define LOG_WRITE MYLOGGER.function1
using namespace std;
class MyLogger{
public:
MyLogger();
template<typename... Args> void deneme(Args... args);
};
extern MyLogger MYLOGGER;
#endif
main.cpp
#include <iostream>
#include "../inc/mylogger.h"
using namespace std;
int main(int argc, char** argv)
{
LOG_WRITE("hello", 3, 4, 1);
return 0;
}
I got this error. undefined reference to `void MyLogger::function1<char, int, int, int>(char, int, int, int)'
I don't understand. How to fix it?