|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
void TestWrite()
{
fstream file;
string s = "xx.txt";
file.open( "test.txt", fstream::in | fstream::out | fstream::app );
file << s <<'\n';
file.close();
}
如题,这段简单的代码在vs 2012下就会报错,通不过编译,我查过相关的文档,说fstream 的运算符重载不支持string.其运算符重载如下:
请高手解释一下为何。
basic_ostream& operator<< (bool& val );
basic_ostream& operator<< (short& val );
basic_ostream& operator<< (unsigned short& val );
basic_ostream& operator<< (int& val );
basic_ostream& operator<< (unsigned int& val );
basic_ostream& operator<< (long& val );
basic_ostream& operator<< (unsigned long& val );
basic_ostream& operator<< (float& val );
basic_ostream& operator<< (double& val );
basic_ostream& operator<< (long double& val );
basic_ostream& operator<< (void*& val );
basic_ostream& operator<< (basic_streambuf<charT,traits>* sb );
basic_ostream& operator<< (basic_ostream& ( *pf )(istream&));
basic_ostream& operator<< (basic_ios<charT,traits>& ( *pf )(basic_ios<charT,traits>&));
basic_ostream& operator<< (ios_base& ( *pf )(ios_base&)); |
|