I'm trying to summarize some experimental results in a file.
The results are generated in various C++ classes and files.
I want them to all write to the same file.
For this reason it would be conventient to have a header that defines everything, and then I can just include it in the files that need to write to it. I should be a singleton, so it is not tried to open the same file twice.
It looks like this:
static FileLogger *s_instance;
logfile = new std::ofstream();
std::cout << "Destructor of logger called" << std::endl;
static std::ofstream *instance()
s_instance = new FileLogger();
std::cout << "got logger" << std::endl;
FileLogger *FileLogger::s_instance = 0;
#endif // FILELOGGER_H
*FileLogger::instance() << "Testoutput" << std::endl;
tries to open a file with the literal name
~/results/experiments.txt. Tilde expansion to your home directory is done by your command shell (probably
bash). You need to use the actual name of your home directory, for example: