4
#include <iostream>
#include <fcntl.h>
#include <fstream>
using namespace std;
class Logger
{
private:
ofstream debug;
Logger()
{
debug.open("debug.txt");
}
static Logger log;
public:
static Logger getLogger()
{
return log;
}
void writeToFile(const char *data)
{
debug << data;
}
void close()
{
debug.close();
}
};
Logger Logger::log;
通過這個類,我試圖創建一個Logger類,它將登錄到一個文件中。但它給錯誤如錯誤:'std :: ios_base :: ios_base(const std :: ios_base&)'是私人的
error: ‘std::ios_base::ios_base(const std::ios_base&)’ is private
我GOOGLE了它,發現它因爲複製的流。據我所知,在這段代碼中沒有複製ofstreams正在發生。
你們能幫我一個忙嗎? 在此先感謝。
〜
感謝一噸:) – Chaitanya
@Chaitanya隨時! –