N
Nan Li
Hello,
Can any one explain why the following code cannot get compiled ??
Thanks.
#include <iostream>
#include <string>
#include <vector>
#include <iterator>
#include <algorithm>
using namespace std;
int main(int argc, char* argv[])
{
struct A
{
void operator()(int i)
{
cout << i << endl;
}
};
vector<int> v(3);
for_each( v.begin(), v.end(), A() );
return 0;
}
c.cpp: In function 'int main(int, char**)':
c.cpp:21: error: no matching function for call to
'for_each(__gnu_cxx::__normal_iterator<int*, std::vector<int,
std::allocator<int> > >, __gnu_cxx::__normal_iterator<int*,
std::vector<int, std::allocator<int> > >, main(int, char**)::A)'
Can any one explain why the following code cannot get compiled ??
Thanks.
#include <iostream>
#include <string>
#include <vector>
#include <iterator>
#include <algorithm>
using namespace std;
int main(int argc, char* argv[])
{
struct A
{
void operator()(int i)
{
cout << i << endl;
}
};
vector<int> v(3);
for_each( v.begin(), v.end(), A() );
return 0;
}
c.cpp: In function 'int main(int, char**)':
c.cpp:21: error: no matching function for call to
'for_each(__gnu_cxx::__normal_iterator<int*, std::vector<int,
std::allocator<int> > >, __gnu_cxx::__normal_iterator<int*,
std::vector<int, std::allocator<int> > >, main(int, char**)::A)'