title: Why am I asked to declare a fucntion from a different file when I have included the header file of that file at the beginning?
body: <p>I thought the entire point of a header file is to avoid repetitive forward declaration? I wrote three c++ files respectively named: fact.c++, fact.h++ (header file), and main.c++. Here are the codes:</p>
  <p>This is fact.c++, storing a function that calculates the factorial of an integer:</p>
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  int factorial(){
      int n;
      cin&gt;&gt;n;
      int fact=1;
      for(int i=1;i&lt;=n;i++){
       fact=fact*i;
       
      }
      return fact;
  }
  </code></pre>
  <p>This is fact.h++, a header file for our fact.c++:</p>
  <pre><code>//the header file for the factorial fucntion from fact.c++ file
  
  #ifndef FACT_H
  #define FACT_H
  
  int factorial();
  
  
  #endif
  </code></pre>
  <p>and finally main.cpp, where the main method is:</p>
  <pre><code>#include &lt;string&gt;
  #include &lt;stdio.h&gt;
  #include &quot;fact.h++&quot;
  using namespace std;
  
  int main(){
  
  cout&lt;&lt;&quot;The factorial value of your number is &quot;&lt;&lt;factorial()&lt;&lt;endl;
  
  }
  
  </code></pre>
  <p>As you can see from above that I have included the fact.h++ header file, expecting not having to declare the factorial function before using it. But when I ran the codes I was told &quot;factorial&quot; was not declared at this scope. I was using Microsoft visual studio code with the coderunner plugin. Why is this happening? Where have I gone wrong?</p>