title: error C2065: undeclared identifier in template function
body: <p>I'm a newbie in C++ and i'm trying to put a little project on wheels, but i'm having a hard time with those errors and i don't know what i'm doing wrong. I think, i've included all neccesary header files.
  What i'm doing wrong?</p>
  
  <p>Thank you in advance!</p>
  
  <p><code>d:\files\visual studio 2010\projects\calculator\aplicatie.cpp(31): error C2065: 'CmdAritmetice' : undeclared identifier</code></p>
  
  <p><code>d:\files\visual studio 2010\projects\calculator\aplicatie.cpp(31): error C2062: type 'int' unexpected</code></p>
  
  <p><code>d:\files\visual studio 2010\projects\calculator\aplicatie.cpp(37): error C2065: 'cmd1' : undeclared identifier</code></p>
  
  <p><code>d:\files\visual studio 2010\projects\calculator\aplicatie.cpp(37): error C2228: left of '.Execute' must have class/struct/union</code></p>
  
  <p><code>type is ''unknown-type''</code></p>
  
  <p><strong>Edit</strong></p>
  
  <p>If i modify <code>CmdAritmetice &lt;int, Suma&gt; cmd1("+");</code> with <code>UI::CmdAritmetice&lt;Calcule::Suma&lt;int&gt;&gt; cmd1("+");</code> the following errors appear when try to compile:</p>
  
  <pre><code>1&gt;d:\files\visual studio 2010\projects\calculator\aplicatie.cpp(32): error C2440: 'specialization' : cannot convert from 'T (__cdecl *)(T,T)' to 'int (__cdecl *)(int,int)'
  1&gt;          None of the functions with this name in scope match the target type
  1&gt;d:\files\visual studio 2010\projects\calculator\aplicatie.cpp(39): error C2660: 'Calculator::UI::CmdAritmetice&lt;Operatie&gt;::Execute' : function does not take 1 arguments
  1&gt;          with
  1&gt;          [
  1&gt;              Operatie=0x0
  1&gt;          ]
  </code></pre>
  
  <p><strong>Main.cpp</strong> </p>
  
  <pre><code>#include "aplicatie.h"
  using namespace Calculator;
  
  int main()
  
  {
      Aplicatie app;
      app.Run();
      return 0;
  }
  </code></pre>
  
  <p><strong>aplicatie.cpp</strong> edited</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include "aplicatie.h"
  #include "Calcule\operatii.h"
  #include "UI\cmdaritmetice.h"
  
  using namespace std;
  
  namespace Calculator{
  
  (...)
  
      void Aplicatie::Run()
      {
          TestSuma();
          CmdAritmetice &lt;int, Suma&gt; cmd1("+");     //here i have errors
          cmd1.Execute("Introduceti doua numere intregi (x, y)");
      }
  
      void Aplicatie::TestSuma()
      {
          int x = 10, y = 20;
          int r = Calcule::Suma(x,y);
      }    
  }
  </code></pre>
  
  <p><strong>cmdaritmetice.h</strong></p>
  
  <pre><code>#ifndef ARITMETICE_H
  #define ARITMETICE_H
  #include "UI\comanda.h"
  
  namespace Calculator{
      namespace UI{
  
          template&lt;int Operatie(int, int)&gt;
          class CmdAritmetice : public ComandaCalcule
          {
  
          public:
              CmdAritmetice(const string &amp;nume) : ComandaCalcule(nume)
              {
              }
              void Execute()
              {
              cout &lt;&lt; Nume() &lt;&lt; endl;
              cout &lt;&lt; "Introduceti doua numere intregi (x, y)\n";
              int x, y;
              cin &gt;&gt; x &gt;&gt; endl;
              cin &gt;&gt; y &gt;&gt; endl;
              cout &lt;&lt; x &lt;&lt; " " &lt;&lt; Nume() &lt;&lt; " " &lt;&lt; y &lt;&lt; " = " &lt;&lt; Operatie (x,y) &lt;&lt;endl;
              }
          };
      }
  }
  #endif
  </code></pre>
  
  <p><strong>LE</strong></p>
  
  <pre><code>**operatii.h**
  
  #ifndef OPERATII_H
  #define OPERATII_H
  
  namespace Calculator{
      namespace Calcule{
  
      template&lt;typename T&gt;
      T Suma(T x, T y)
      {
          return x + y;
      }
  
  }
  #endif
  </code></pre>