I'm trying to compile some older code written in C++ and am getting this error:
log.cpp: In constructor `Log::Log(std::string)':
log.cpp:36: error: no matching function for call to `std::basic_ofstream<char, std::char_traits<char> >:
pen(__gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, const std::_Ios_Openmode&)'
/usr/lib/gcc/i486-slackware-linux/3.4.6/../../../../include/c++/3.4.6/fstream:695: note: candidates are: void std::basic_ofstream<_CharT, _Traits>:
pen(const char*, std::_Ios_Openmode) [with _CharT = char, _Traits = std::char_traits<char>]
make[1]: *** [log.o] Error 1
The file log.cpp contains this:
Code:
#include <string>
#include <iostream>
#include <fstream>
using namespace std;
#include "log.h"
/**
* Opens up a log file called \e fname for appending.
*
* \param fname the name of the file to log to.
*/
Log::Log ( string fname )
{
logfile.open ( fname.begin ( ), ios::app );
}
/**
* Records a string to the log file
*
* \param s the string to be appended to the log file
*/
void Log::record ( string s )
{
logfile << s << endl;
}
/**
* Closes down the log file
*/
Log::~Log ( )
{
logfile.close ( );
}
Can anyone suggest how to fix this? I am using gcc-3.4.6 with glibc-2.3.6 (but preferably the fix should work with gcc-4.x and glibc>=2.4).