title: Do template declarations only work for the function they are immediately declared before
body: <p>I'm writing an example program to help build an understanding of templates in C++. I am trying to use a template class to have more than one functionality.</p>
  
  <p>Below is the following code I have written up.</p>
  
  <pre><code>// Example program
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  using namespace std;
  
  template&lt;class test&gt;
  test addstuff(test a, test b){
      return a+b;
  }
  test multiplystuff(test a,test b){
      return a*b;
  }
  
  int main()
  {
    double a,b,c;
    cout &lt;&lt; "Enter a value for a." &lt;&lt; endl;
    cin &gt;&gt; a;
    cout &lt;&lt; "Enter a value for a." &lt;&lt; endl;
    cin &gt;&gt; b;
    c = addstuff(a,b);
    cout &lt;&lt; c &lt;&lt; endl;
    c = multiplystuff(a,b);
    cout &lt;&lt; c &lt;&lt; endl;
  
  }
  </code></pre>
  
  <p>The error I am getting is in the test <code>multiplystuff</code> in my function, it is not within scope is the error I receive. I expect the template to be able to handle more than one functionality, What could the problem be?</p>