Language C Objective Write a function named avgWeight that t
Language: C++
Objective: Write a function named avgWeight that takes a single argument, which is a vector of pointers to User objects, and returns their average weight as a double. You are given the following class declaration for User:
Constraints:
The vector is guaranteed to contain at least one user.
Do not print anything. The main that has been provided prints the result.
Test Input: You can provide test input by creating lines of the form
For example:
Solution
double avgWeight(vector <User*> v)
{
int s=v.size();
double avg=0;
for(int i=0;i<s;i++){
avg += v[i]->weight;
}
return (avg/s)
}
