#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 クラスを作成しようとしています。しかし、次のようなエラーが発生します
error: ‘std::ios_base::ios_base(const std::ios_base&)’ is private
私はそれをグーグルで調べたところ、ストリームのコピーが原因であることがわかりました。このコードで理解している限り、ofstreams のコピーは行われていません。
みんな私を助けてくれませんか。前もって感謝します。
〜