The problem you have is that your vector stores pointers, so the std::accumulate
will calculate the sum of the pointers.
You have to use the four-argument version of std::accumulate
, and provide your own function which does the calculations properly, something like
dMean = std::accumulate(
m_vectorData.begin(), m_vectorData.end(), 0.0,
[] (const double acc, const CData* data) { return acc + data->getData(); }
);