I've been trying to do Ex. 10-02 in Accelerated C++, and it was giving me errors and I eventually kept "simplifying" my program until I got to this point, and even still it wouldn't compile (via g++) giving me the error:
test.cpp: In function ‘int main()’:
test.cpp:22: error: no matching function for call to ‘dumb(__gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >, __gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >)’
Here's my program:
#include <algorithm>
#include <iostream>
#include <vector>
using std::cout; using std::endl;
using std::vector;
template <class Ran, class T> T dumb(Ran begin, Ran end)
{
return *begin;
}
int main()
{
vector<int> myVector;
for (int i = 1; i <= 9; ++i)
myVector.push_back(i);
int d = dumb(myVector.begin(), myVector.end());
cout << "Value = " << d << endl;
return 0;
}
What's causing this error?