78 cout <<
"Hello world!" << endl;
94 cout <<
" -------- New in v_10c --------------\n";
99 v.push_back(
new Raba(3600, 4000) );
100 v.push_back(
new Opel(1450) );
101 v.push_back(
new MAN(1200, 12000) );
102 v.push_back(
new Smart(950) );
103 v.push_back(
new Smart(1100));
107 cout <<
" -------- after sort (standard --> incorrect) -------------\n";
108 sort(v.begin(),v.end());
111 cout <<
" -------- only the pointers have been compared -------------\n";
113 cout <<
" -------- after sort (compare regarding fuel consumption) -------------\n";
117 cout <<
" -------- correct-------------\n";
122 for (
unsigned int i=0; i<v.size(); ++i)
124 sum += v[i]->verbrauch();
126 cout <<
"konv: durchschnittlicher Verbrauch: " << sum/v.size() << endl;
129 float sum2 =accumulate(v.begin(), v.end(), 0.0f,
add_fuel);
130 cout <<
"accu: durchschnittlicher Verbrauch: " << sum2/v.size() << endl;
133 cout <<
" -------- sort using lambda function for 'operator>' -------------\n";
136 sort(v.begin(),v.end(),
139 return aa->verbrauch() > cc->verbrauch();
ostream & operator<<(ostream &s, const Fahrzeug &p)
Prints some info from a vehicle.
bool fuel_consumption(const Fahrzeug *a, const Fahrzeug *b)
Compares the fuel consumption between two vehicles.
float add_fuel(float x, const Fahrzeug *y)
Adds the fuel consumption of a vehicle y to quantity x.