the following code cannot pass the compiler:
#include <fstream>
#include <iostream>
using namespace std;
int main()
{
fstream outfile("i:\\test.txt", ios_base::in | ios_base::out);
long lFlag = outfile.flags();
outfile.setf(ios_base::app);
cout << hex << "Original flag : " << lFlag << '\n'
<< "Now flag : " << outfile.flags() << '\n';
if (outfile.flags() & ios_base::app)
cout << "append bit set!\n";
char ch;
while (cin >> ch)
outfile << ch;
cout << '\n';
outfile.seekg(0);
while (outfile.get(ch))
cout << ch;
cout << '\n';
return 0;
}
the compiler returns the errors:
test3.cpp: In function `int main()':
test3.cpp:11: no matching function for call to
`std::basic_fstream<char,
std::char_traits<char> >::setf(const std::_Ios_Openmode&)'
i:/mingw/include/c++/3.2/bits/ios_base.h:342: candidates are:
std::_Ios_Fmtflags std::ios_base::setf(std::_Ios_Fmtflags)
i:/mingw/include/c++/3.2/bits/ios_base.h:350:
std::_Ios_Fmtflags std::ios_base::setf(std::_Ios_Fmtflags,
std::_Ios_Fmtflags)
but there is no problem with both bcc5.5 and vc6.0.
my system is Windows2000 and i use the gcc2.3.2 shipped with
mingw2.0.3.
what's the matter with gcc2.3.2 or my program?