title: error C3861: identifier not found
body: <p>I encountered the following problem with this code.   </p>
  
  <pre><code> #include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;vector&gt;
  #include &lt;algorithm&gt;
  #include &lt;iomanip&gt;
  
  //////////////////////////////////////////////////////////
  //////////////////////////CORE CLASS//////////////////////
  //////////////////////////////////////////////////////////
  class Core {
  public:
      Core() : midterm(0), final(0) { }
      Core(std::istream&amp; is) { read(is); }
  
      std::string name() const;
  
      virtual std::istream&amp; read(std::istream&amp;);
      virtual double grade() const;
  protected:
      std::istream&amp; read_common(std::istream&amp;);
      std::istream&amp; read_hw(std::istream&amp;, std::vector&lt;double&gt;&amp;);
      double midterm, final;
      std::vector&lt;double&gt; homework;
  private:    
      std::string n;  
  };
  
  std::string Core::name() const { return n; }
  
  double Core::grade() const
  {
      return calc_grade(midterm, final, homework);
  }
  
  std::istream&amp; Core::read_common(std::istream&amp; in)
  {
      in &gt;&gt; n &gt;&gt; midterm &gt;&gt; final;
      return in;
  }
  
  std::istream&amp; Core::read(std::istream&amp; in)
  {
      read_common(in);
      read_hw(in, homework);
      return in;
  }
  
  std::istream&amp; Core::read_hw(std::istream&amp; in, std::vector&lt;double&gt;&amp; homework)
  {
      double input;
      while (in &gt;&gt; input)
          homework.push_back(input);
  
      return in;
  }
  
  //////////////////////////////////////////////////////////
  //////////////////////////GRAD CLASS//////////////////////
  //////////////////////////////////////////////////////////
  class Grad : public Core {
  public:
      Grad() : thesis(0) { }
      Grad(std::istream&amp; is) { read(is); }
  
      double grade() const;
      std::istream&amp; read(std::istream&amp;);
  private:
      double thesis;
  };
  
  std::istream&amp; Grad::read(std::istream&amp; in)
  {
      read_common(in);
      in &gt;&gt; thesis;
      read_hw(in, homework);
      return in;
  }
  
  double Grad::grade() const
  {
      return std::min(Core::grade(), thesis);
  }
  
  //////////////////////////////////////////////////////////
  //////////////////////MISCELLANEOUS///////////////////////
  //////////////////////////////////////////////////////////
  bool compare_grades(const Core&amp; c1, const Core&amp; c2)
  {
      return c1.grade() &lt; c2.grade();
  }
  
  bool compare_Core_ptrs(const Core* cp1, const Core* cp2)
  {
      return compare_grades(*cp1, *cp2);
  }
  
  double calc_grade(double midterm, double final, std::vector&lt;double&gt;&amp; homework)
  {
      double result = 0.0;
      for (std::vector&lt;double&gt;::const_iterator i = homework.begin(); i != homework.end(); ++i)
          result += *i;
  
      return midterm*0.4 + final*0.4 + (result / homework.size())*0.2;
  }
  
  using namespace std;
  
  int main()
  {
      vector&lt;Core*&gt; students;
      Core* record;
      char ch;
      string::size_type maxlen = 0;
  
      while (cin &gt;&gt; ch)
      {
          if (ch == 'U')
              record = new Core;
          else
              record = new Grad;
          record-&gt;read(cin);
          maxlen = max(maxlen, record-&gt;name().size());
          students.push_back(record);
      }
  
      sort(students.begin(), students.end(), compare_Core_ptrs);
  
      for (vector&lt;Core*&gt;::size_type i = 0; i != students.size(); ++i)
      {
          cout &lt;&lt; students[i]-&gt;name() &lt;&lt; string(maxlen + 1 - students[i]-&gt;name().size(), ' ');
          try
          {
              double final_grade = students[i]-&gt;grade();
              streamsize prec = cout.precision();
              cout &lt;&lt; setprecision(3) &lt;&lt; final_grade &lt;&lt; setprecision(prec) &lt;&lt; endl;
          }
          catch (domain_error e)
          {
              cout &lt;&lt; e.what() &lt;&lt; endl;
          }
          delete students[i];
      }
      return 0;
  }
  </code></pre>
  
  <p>error C3861: 'calc_grade': identifier not found. I tried to move the function before the classes but nothing changed. I don't understand what is wrong. Help.</p>