log.h
来自「文化算法的实际应用」· C头文件 代码 · 共 62 行
H
62 行
#include <string>
#include <fstream>
#include <iostream>
using namespace std;
class CALog
{
private:
string mFileName;
bool mIsAppend;
public:
ofstream out;
void Open(string fileName, bool isAppend)
{
mIsAppend = isAppend;
mFileName = fileName;
try
{
if(mIsAppend)
{
out.open(mFileName.c_str(), ios::app);
}
else
{
out.open(mFileName.c_str());
}
}
catch(...)
{
exit(-1);
}
}
ostream& operator<<(const string& s)
{
out<<s;
return out;
}
ostream& operator<<(const float f)
{
out<<f;
return out;
}
ostream& operator<<(const double d)
{
out<<d;
return out;
}
void Log(string s)
{
out<<s<<endl;
}
};
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?