我试图修改我的日志类以接受我的字符串中的变量.例如,如果我想输出一个区域中有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个玩家
有任何解决这个问题的方法吗?