有几个错误大家帮改一下
#include<iterator>
#include<fstream>
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;
void main()
{
istream_iterator<int> is_string(cin),eos;
ofstream outfile("text1");
ostream_iterator<int> out_string(outfile);
vector<int> vec;
copy(is_string,eos,back_inserter(vec));
vector<int>::iterator iter=vec.begin();
while((iter=find_if(iter,vec.end(),not1(bind2nd(modulus<int>(),2))))!=vec.end())
{
copy(iter,iter+1,outfile);
}
}
问题点数:20、回复次数:7Top
1 楼gsp397(火烧耳朵)回复于 2003-08-02 23:11:21 得分 0
还有这个为什么错误?
#include<functional>
#include<iostream>
using namespace std;
void main()
{
plus<int> intAdd;
int i=BinaryFunc(plus<double>(),2,3);
cout<<i<<endl;
}Top
2 楼gsp397(火烧耳朵)回复于 2003-08-03 11:16:35 得分 0
自己upTop
3 楼gsp397(火烧耳朵)回复于 2003-08-03 11:42:52 得分 0
再upTop
4 楼zhz44(任我行)回复于 2003-08-03 19:17:34 得分 5
老兄,你把错误提示贴出来行吗?Top
5 楼gsp397(火烧耳朵)回复于 2003-08-04 11:27:37 得分 0
第一个程序的错误提示
--------------------Configuration: Cpp6 - Win32 Debug--------------------
Compiling...
Cpp6.cpp
d:\microsoft visual studio\vc98\include\xutility(18) : error C2675: unary '++' : 'class std::basic_ofstream<char,struct std::char_traits<char> >' does not define this operator or a conversion to a type acceptable to the predefined operator
e:\我的程序\c++ primer'\cpp6.cpp(18) : see reference to function template instantiation 'class std::basic_ofstream<char,struct std::char_traits<char> > __cdecl std::copy(int *,int *,class std::basic_ofstream<char,struct std::char_traits<char
> >)' being compiled
d:\microsoft visual studio\vc98\include\xutility(19) : error C2100: illegal indirection
e:\我的程序\c++ primer'\cpp6.cpp(18) : see reference to function template instantiation 'class std::basic_ofstream<char,struct std::char_traits<char> > __cdecl std::copy(int *,int *,class std::basic_ofstream<char,struct std::char_traits<char
> >)' being compiled
d:\microsoft visual studio\vc98\include\xutility(19) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'int' (or there is no acceptable conversion)
e:\我的程序\c++ primer'\cpp6.cpp(18) : see reference to function template instantiation 'class std::basic_ofstream<char,struct std::char_traits<char> > __cdecl std::copy(int *,int *,class std::basic_ofstream<char,struct std::char_traits<char
> >)' being compiled
Error executing cl.exe.
Cpp6.obj - 3 error(s), 0 warning(s)
第二个程序的错无提示
--------------------Configuration: Cpp6 - Win32 Debug--------------------
Compiling...
Cpp6.cpp
e:\我的程序\c++ primer'\cpp6.cpp(7) : error C2065: 'BinaryFunc' : undeclared identifier
Error executing cl.exe.
Cpp6.obj - 1 error(s), 0 warning(s)
Top
6 楼chon81(当我遇上你…)回复于 2003-08-04 11:54:15 得分 6
第二个错误是找不到BinaryFunc()函数Top
7 楼zhz44(任我行)回复于 2003-08-10 11:50:10 得分 9
是操做符重载的问题。查查书吧。Top




