Question: 2 2 ) Function Object Class Usage HomeworkUnanswered Given the following Sum function object class: class Sum { double sum; public: Sum ( double s

22) Function Object Class Usage
HomeworkUnanswered
Given the following Sum function object class:
class Sum { double sum; public: Sum(double s =0.0) : sum{s}{}// create double operator()(double num){ return sum += num; }// update double operator()(void) const { return sum; }// access double reset(double s =0.0){ swap(sum, s); return s; }//[re]initialize };
Show how to use it to calculate the average of the elements in the following array. (What kind of loop would be most appropriate here?)(The declarations are normative; the initializations are illustrative.)
const size_t MAX{50}; long a[MAX]={10,14,12,8,10,6,9,13,7,11}; size_t num_as{10};

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!