I'm just trying to figure out how this stuff works. I wrote this function:
#include <algorithm>
#include <vector>
double VectorMax(const vector<double> &a)
{
vector<double>::iterator pos;
pos = max_element (a.begin(), a.end());
return *pos;
}
and call it with:
vector<double> Numbers;
Numbers.push_back(3.4);
Numbers.push_back(4.5);
Numbers.push_back(1.2);
cout << VectorMax(Numbers) << endl;
but I get "no match for operator=" error. Since this is just a container of doubles, shouldn't = already be defined?
Thanks,
Dave