上代码:
#include <iostream>
#include <iterator>
#include <algorithm>
#include <string>
#include <vector>
#include <fstream>
using namespace std;
int main( void )
{
string from,to;
cin >> from ;
cin >> to;
ifstream is( from.c_str() );
istream_iterator ii(is);
istream_iterator eos;
vector b(ii,eos); //此处vc6.0编译器提示一个错,见下面备注处。
sort(b.begin(),b.end());
ofstream os(to.c_str());
ostream_iterator oo(os,"\n");
unique_copy(b.begin(),b.end(),oo);
return (!is.eof() || !os);
}
备注:编译错误提示信息
--------------------Configuration: IOiterator - Win32 Debug--------------------
Compiling...
IOiterator.cpp
G:\VC6.0 TestCode_C\IOiterator.cpp(20) : error C2664: '__thiscall std::vector,class std::allocator >,class std::allocator,cla
ss std::allocator > > >::std::vector,class std::allocator >,class std::allocator,class std::allocator > > >(unsig
ned int,const class std::basic_string,class std::allocator > &,const class std::allocator,class std::allocator > > &)' : cannot convert paramet
er 1 from 'class std::istream_iterator,class std::allocator >,char,struct std::char_traits >' to 'unsigned int'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
执行 cl.exe 时出错.
IOiterator.obj - 1 error(s), 0 warning(s)
-------------------------错误提示完毕----------------------------------
在vs2008版本以上运行正常。
---------------------------------------- 2019年09月11日 更新 -------------------------------------------
VC++6.0已经诞生超过20年,应该被淘汰了!后来者看到此篇文章,请抛弃VC++6.0,更换为VS2008、VS2013、VS2015、VS2017都可以!