Thinking in C++

A

Alex Buell

Could anyone tell me why this program taken from the Thinking in C++
book won't compile with GCC 4.1.2? Here's the error:

C++ Binder.o
Binder.cpp: In function ‘int main()’:
Binder.cpp:19: error: no matching function for call to ‘copy
( said:
&)’ /usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include/g+
+-v4/bits/stl_algobase.h:376: note: candidates are: _OutputIterator
std::copy(_InputIterator, _InputIterator, _OutputIterator) [with
_InputIterator = __gnu_cxx::__normal_iterator<int*,
std::vector<int, std::allocator<int> > >, _OutputIterator =
std::eek:stream_iterator<int, char, std::char_traits<char> >]

And here's the program itself:

#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <iostream>
#include <iterator>
#include <vector>
#include "Generators.h"

using namespace std;

int main()
{
ostream_iterator<int> out(cout, " ");
vector<int> v(15);
srand(time(0));

generate(v.begin(), v.end(), URandGen(20));
copy(v.begin, v.end(), out);
transform(v.begin(), v.end(), v.begin(), bind2nd(multiplies<int>
(), 10)); copy(v.begin(), v.end(), out); }

The odd thing is that if I comment out the first copy() call, it
compiles just fine?

Thanks,
Alex
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top