title: Getting error message "Not declared in scope"
body: <p>I am working on a C++ project and while compiling, I am receiving the error messages:</p>
  
  <blockquote>
    <p>error: <code>mean</code> was not declared in this scope<br>
    error: <code>standard_dev</code> was not declared in this scope</p>
  </blockquote>
  
  <p>My code is </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;iomanip&gt;
  #include &lt;fstream&gt;
  #include &lt;cmath&gt;
  #include &lt;string&gt;
  
  using namespace std;
  
  int main()
  {
      int N(0);
      char filename[100];
      double m, stdev;
      string temp;
  
      double next;
      int count = 0;
      cout &lt;&lt; "Enter name of file: ";
      cin &gt;&gt; filename;
  
      ifstream myfile;
      myfile.open(filename);
      while (myfile &gt;&gt; next)
      {
          count++;
      }
      N = count;
      double* mydata;
      mydata = new double[N];
  
      for (int i = 0; i &lt; N; i++)
      {
          myfile &gt;&gt; mydata[i];
      }
      m = mean(mydata, N);
      stdev = standard_dev(mydata, m, N);
      cout &lt;&lt; "The standard deviation is:" &lt;&lt; stdev &lt;&lt; endl;
  
      myfile.close();
      delete[] mydata;
      return 0;
  }
  
  double mean(double* mydata, double N)
  {
      double sum(0), m;
      for (int i = 0; i &lt; N; i++)
      {
          sum += mydata[i];
      }
      m = (sum / (double) N);
      return (m);
  }
  double standard_dev(double* mydata, double m, int N)
  {
      double* mydata2 = new double[N];
      for (int i = 0; i &lt; N; i++)
      {
          mydata2[i] = pow((mydata[i] - m), 2);
      }
      double sum(0), S, X;
      for (int i = 0; i &lt; N; i++)
      {
          sum += mydata2[i];
      }
      X = sum / N;
      S = sqrt(X);
      return (S);
  }
  </code></pre>