Put the function outside of the class (which I don't think is required following the discussion :-) ) and if the Statistics
class is for some reason required, provide an accessor to sample
e.g.
namespace utilitystuff
{
double calcCovariance(const vector<double> &s1, const vector<double> &s2)
{
//definition
}
}
Accessor to sample:
const vector<double>& Statistics::getSample{return sample;}
And call it like so:
//Assuming we have Statistics objects stats1 and stats2.
double covariance = utilitystuff::calcCovariance(stats1.getSample(), stats2.getSample());