Accelerated C++problem - functions which call functions
<p>I am having trouble with an exercise in Accelerated C++.
The main function is as follows:</p>

<pre><code>int main()
{
 // students who did and didn't do all their homework
 vector&lt;Student_info&gt; did, didnt;

 // read the student records and partition them
 Student_info student;
 while (read(cin, student)) {
  if (did_all_hw(student))
   did.push_back(student);
  else
   didnt.push_back(student);
 }

 // verify that the analyses will show us something
 if (did.empty()) {
  cout &lt;&lt; "No student did all the homework!" &lt;&lt; endl;
  return 1;
 }
 if (didnt.empty()) {
  cout &lt;&lt; "Every student did all the homework!" &lt;&lt; endl;
  return 1;
 }


 // do the analyses
 write_analysis(cout, "median", median_analysis, did, didnt);
 write_analysis(cout, "average", average_analysis, did, didnt);
 write_analysis(cout, "median of homework turned in",
                optimistic_median_analysis, did, didnt);

 return 0;
}
</code></pre>

<p>The function write_analysis takes 5 parameters, the third of which, analysis, is a function.</p>

<p>Write analysis is as follows:</p>

<pre><code>void write_analysis(ostream&amp; out, const string&amp; name,
                    double analysis(const vector&lt;Student_info&gt;&amp;),
                    const vector&lt;Student_info&gt;&amp; did,
                    const vector&lt;Student_info&gt;&amp; didnt)
{
 out &lt;&lt; name &lt;&lt; ": median(did) = " &lt;&lt; analysis(did) &lt;&lt;
                ", median(didnt) = " &lt;&lt; analysis(didnt) &lt;&lt; endl;
}
</code></pre>

<p>The question asks the reader to write an analysis function to call optimistic_median, where optimistic median is:</p>

<pre><code>double optimistic_median(const Student_info&amp; s)
{
 vector&lt;double&gt; nonzero;
 remove_copy(s.homework.begin(), s.homework.end(),
             back_inserter(nonzero), 0);

 if (nonzero.empty())
  return grade(s.midterm, s.final, 0);
 else
  return grade(s.midterm, s.final, median(nonzero));
}
</code></pre>

<p>Then, presumably, one can get the write_analysis function to work, which it does not seem to do for me.
I have tried </p>

<pre><code>double analysis(const Student_info&amp; s)
{ 

 optimistic_median(s);

}
</code></pre>

<p>But it doesn’t work. 
Anyone able to help?</p>
