Hello,
could anyone explain me how do this below? I need to return the number of elements summed in way to do the mean. Is there anybody, please?
class Value {
public:
double _value;
bool _missed;
bool getMissed() const { return _missed; }
//other methods....
};
class Other {
vector<Value> _values;
static double sum_values(const double& accum, const Value& right) {
if ( right.getMissed() ) return accum;
return accum + right._value;
}
void computeMean() {
double mean = std::accumulate( _values.begin(), _values.end(), 0.0,
Other::sum_values );
}
};
class Value {
public:
double _value;
bool _missed;
bool getMissed() const { return _missed; }
//other methods....
};
class Other {
vector<Value> _values;
static double sum_values(const double& accum, const Value& right) {
if ( right.getMissed() ) return accum;
return accum + right._value;
}
void computeMean() {
double mean = std::accumulate( _values.begin(), _values.end(), 0.0,
Other::sum_values );
}
};
To copy to clipboard, switch view to plain text mode
Bookmarks