Skip to main content

14.3) Example: Statistical Analysis Program As Multiple Files


Thematically, the code can divided into 'input/output', 'statistical calculation' and 'program entry point', each of which can be a separate file. This gives rise to the structure below.

data.cpp:

void read_data(ifstream& input, vector<double>& data)
{
  ...
}

stats.cpp:

double mean(const vector<double>& data)
{
  ...
}
double stdev(const vector<double>& data)
{
  ...
}

main.cpp:

int main(int argc, char* argv[])
{
  ...
}