Mam problem z funkcją, która ma zwracać największy element z wektora struktur vector<Car>, gdzie w strukturze przetczymuje informacje o nazwie samochodu, roku powstania, kraju i prędkości...
Wszystko oprócz podanego niżej kodu działa bez zarzutu.
bool predicat_to_max(Car a, Car b) //ex.D
{
if (a.speed > b.speed)
{
return true;
}
}
void exD(vector<Car>list) //ex.D
{
auto it = max(list.begin(), list.end(), predicat_to_max);
cout << "The fastest car " << it->brand << "\nV-max= " << it->speed << "\ncountry " << it->country << "year " << it->year;
}
nie wiem, co robię tu nie tak.
1>c:\users\lenovo\desktop\politechnika\informatyka\zadaniac++\zadanie12_1\zadanie12_1\zadanie12_1\main.cpp(49): warning C4018: '<' : signed/unsigned mismatch
1>c:\users\lenovo\desktop\politechnika\informatyka\zadaniac++\zadanie12_1\zadanie12_1\zadanie12_1\main.cpp(61): warning C4018: '<' : signed/unsigned mismatch
1>c:\users\lenovo\desktop\politechnika\informatyka\zadaniac++\zadanie12_1\zadanie12_1\zadanie12_1\main.cpp(112): warning C4018: '<' : signed/unsigned mismatch
1>c:\program files (x86)\microsoft visual studio 12.0\vc\include\xutility(521): error C2664: 'bool (Car,Car)' : cannot convert argument 2 from 'const std::_Vector_iterator<std::_Vector_val<std::_Simple_types<Car>>>' to 'Car'
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\algorithm(4103) : see reference to function template instantiation 'bool std::_Debug_lt_pred<bool(__cdecl *)(Car,Car),const _Ty&,const _Ty&>(_Pr,_Ty1,_Ty2,std::_Dbfile_t,std::_Dbline_t)' being compiled
1> with
1> [
1> _Ty=std::_Vector_iterator<std::_Vector_val<std::_Simple_types<Car>>>
1> , _Pr=bool (__cdecl *)(Car,Car)
1> , _Ty1=const std::_Vector_iterator<std::_Vector_val<std::_Simple_types<Car>>> &
1> , _Ty2=const std::_Vector_iterator<std::_Vector_val<std::_Simple_types<Car>>> &
1> ]
1> c:\users\lenovo\desktop\politechnika\informatyka\zadaniac++\zadanie12_1\zadanie12_1\zadanie12_1\main.cpp(128) : see reference to function template instantiation 'const _Ty &std::max<std::_Vector_iterator<std::_Vector_val<std::_Simple_types<Car>>>,bool(__cdecl *)(Car,Car)>(const _Ty &,const _Ty &,_Pr)' being compiled
1> with
1> [
1> _Ty=std::_Vector_iterator<std::_Vector_val<std::_Simple_types<Car>>>
1> , _Pr=bool (__cdecl *)(Car,Car)
1> ]
1>c:\program files (x86)\microsoft visual studio 12.0\vc\include\xutility(521): error C2664: 'bool (Car,Car)' : cannot convert argument 1 from 'const std::_Vector_iterator<std::_Vector_val<std::_Simple_types<Car>>>' to 'Car'
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1>c:\program files (x86)\microsoft visual studio 12.0\vc\include\xutility(523): error C2664: 'bool (Car,Car)' : cannot convert argument 2 from 'const std::_Vector_iterator<std::_Vector_val<std::_Simple_types<Car>>>' to 'Car'
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1>c:\program files (x86)\microsoft visual studio 12.0\vc\include\xutility(523): error C2664: 'bool (Car,Car)' : cannot convert argument 1 from 'const std::_Vector_iterator<std::_Vector_val<std::_Simple_types<Car>>>' to 'Car'
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========