Fahrzeuge 3: shared pointer
main.cpp File Reference
#include "fahrzeug.h"
#include <algorithm>
#include <iostream>
#include <memory>
#include <numeric>
#include <typeinfo>
#include <vector>
Include dependency graph for main.cpp:

Go to the source code of this file.

Functions

ostream & operator<< (ostream &s, const Fahrzeug &p)
 Prints some info from a vehicle. More...
 
ostream & operator<< (ostream &s, const vector< shared_ptr< Fahrzeug >> &v)
 Prints the whole vector of base class pointers. More...
 
bool fuel_consumption (const shared_ptr< Fahrzeug > &a, const shared_ptr< Fahrzeug > &b)
 Compares the fuel consumption between two vehicles. More...
 
float add_fuel (float x, const shared_ptr< Fahrzeug > &y)
 Adds the fuel consumption of a vehicle y to quantity x. More...
 
int main ()
 

Function Documentation

◆ add_fuel()

float add_fuel ( float  x,
const shared_ptr< Fahrzeug > &  y 
)

Adds the fuel consumption of a vehicle y to quantity x.

Parameters
[in]xgiven quantity
[in]ybase class pointer to vehicle
Returns
x+y.fuel

Definition at line 65 of file main.cpp.

Here is the caller graph for this function:

◆ fuel_consumption()

bool fuel_consumption ( const shared_ptr< Fahrzeug > &  a,
const shared_ptr< Fahrzeug > &  b 
)

Compares the fuel consumption between two vehicles.

Parameters
[in]abase class pointer to first vehicle
[in]bbase class pointer to second vehicle
Returns
true if a needs less fuel than b

Definition at line 51 of file main.cpp.

Here is the caller graph for this function:

◆ main()

int main ( )

Definition at line 70 of file main.cpp.

Here is the call graph for this function:

◆ operator<<() [1/2]

ostream & operator<< ( ostream &  s,
const Fahrzeug p 
)

Prints some info from a vehicle.

Parameters
[in,out]soutput stream
[in]pa general vehicle
Returns
changed output stream

Definition at line 138 of file main.cpp.

Here is the call graph for this function:

◆ operator<<() [2/2]

ostream & operator<< ( ostream &  s,
const vector< shared_ptr< Fahrzeug >> &  v 
)

Prints the whole vector of base class pointers.

Parameters
[in,out]soutput stream
[in]vvector of base class pointers
Returns
changed output stream

Definition at line 150 of file main.cpp.