修改日志类以接受string - C++中的变量

1 c++ io logging

我试图修改我的日志类以接受我的字符串中的变量.例如,如果我想输出一个区域中有7个玩家.

这是我写入日志功能:

void Log::writeSuccess(string text,...)
{
    // Write the sucessfull operation to the logfile
    logfile << "<---> " << text << endl;
}
Run Code Online (Sandbox Code Playgroud)

这是我的调用代码:

int playernum = 7;

errorLog.writeSuccess("There are %i players in the area", playernum);
Run Code Online (Sandbox Code Playgroud)

它最终输出到文件:该区域有%i个玩家

有任何解决这个问题的方法吗?

Arm*_*yan 6

我想知道你的程序到底是怎么编的?!writeSuccess使用2个参数调用,而声明只使用一个参数.

你应该看看boost格式