Hello everyone, i just signed up with Daniweb hoping you guys give help me out. I'm reading c++ primer plus(4th edition) and needed some help with a program exercise on chapter 9.
well here it is.
2. This the namespace
namespace SALES
{
const int QUARTERS = 4;
struct Sales
{
double sales[QUARTERS];
double average;
double max;
double min;
};
// copies the lesser of 4 or n items from the array ar
// to the sales member of s and computes and stores the
// average, maximum, and minimum values of the entered items;
// remaining elements of sales, if any, set to 0
void setSales(Sales & s, const double ar[], int n);
// gathers sales for 4 quarters interactively, stores them
// in the sales member of s and computes and stores the
// average, maximum, and minumum values
void setSales(Sales & s);
// display all information in structure s
void showSales(const Sales & s);
}
Write a three-file program based on this namespace. The first file should be a header file containing the namespace. The second file should be a source code file extending the namespace to provide definitions for the three prototyped functions. The third file should
declare two Sales objects. It should use the interactive version of setSales() to provide values for one structure and the non-interactive version of setSales() to provide values for the second structure. It should display the contents of both structures by using showSales() .
My problem is not coding but rather the flow of the program. Actually my real problem is the overloaded setSales function. I don't understand really what's suppose happen?Can someone maybe just simplify an explanation of the program flow? Any help would be great thanks.