Używanie std :: max_element w wektorze <podwójne>
Próbuję użyćstd::min_element
istd::max_element
aby zwrócić elementy min i max w wektorze podwójnym. Mój kompilator nie lubi tego, jak obecnie próbuję ich używać, i nie rozumiem komunikatu o błędzie. Mogę oczywiście napisać własną procedurę, aby znaleźć min / max, ale chciałbym zrozumieć, jak korzystać z funkcji.
<code>#include <vector> #include <algorithm> using namespace std; int main(int argc, char** argv) { double cLower, cUpper; vector<double> C; // code to insert values in C not shown here cLower = min_element(C.begin(), C.end()); cUpper = max_element(C.begin(), C.end()); return 0; } </code>
Oto błąd kompilatora:
<code>../MIXD.cpp:84: error: cannot convert '__gnu_cxx::__normal_iterator<double*, std::vector<double, std::allocator<double> > >' to 'double' in assignment ../MIXD.cpp:85: error: cannot convert '__gnu_cxx::__normal_iterator<double*, std::vector<double, std::allocator<double> > >' to 'double' in assignment </code>
Czy ktoś mógłby wyjaśnić, co robię źle?