【发布时间】:2021-10-16 18:57:40
【问题描述】:
我一直在写这个类来记录日志,但我一直没有解决这个问题。
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;
}
我收到了这个错误。
对 `void MyLogger::function1
我不明白。如何解决?
【问题讨论】:
标签: c++ function class templates arguments