measure.cpp
/*
  Calculate the average/mean value for all the values. This function should be
  callable from a constant context and must promise to not change the state of 
  the instance or throw an exception.

  @return
    The average value for all the years, or 0 if it cannot be calculated

  @example
    Measure measure("pop", "Population");
    measure.setValue(1999, 12345678.9);
    measure.setValue(2001, 12345679.9);
    auto diff = measure.getAverage(); // returns 12345678.4
*/
Calculate the average/mean value for all the values. This function should be
callable from a constant context and must promise to not change the state of
the instance or throw an exception.
Calculate the average / mean value for all the values . This function should be callable from a constant context and must promise to not change the state of the instance or throw an exception .
double Measure::getAverage() const{
    if(readings.size() == 0)
        return 0;
    double sum = 0;
    for (auto const& reading : readings)
        sum += reading.second;
    return (sum/readings.size());
}
double Measure :: getAverage ( ) const { if ( readings . size ( ) == 0 ) return 0 ; double sum = 0 ; for ( auto const & reading : readings ) sum += reading . second ; return ( sum / readings . size ( ) ) ; }
Calculate the average/mean value for all the values.
Calculate the average / mean value for all the values .