title: C++ Specializing single member function
body: <p>Problems with class template member specialization.</p>
  <p>I have a simple class and I want specialize a single member function. I'm doing like this:</p>
  <pre><code>template &lt;class T&gt;
  class Object
  {
  public:
      Object() {}
  
      void print() const
      {
          std::cout &lt;&lt; &quot;It's the template&quot; &lt;&lt; std::endl;
      }
      // ...
  };
  
  template&lt;&gt;
  void Object&lt;int&gt;::print() const
  {
      std::cout &lt;&lt; &quot;It's an int&quot; &lt;&lt; std::endl;
  }
  </code></pre>
  <p>which ends up in a compile error for multiple definition of the member function.</p>
  <p>If just one source file includes the header everything is fine.</p>
  <p>If two files include the header I get the following error:</p>
  <blockquote>
  <p>/home/marc/QtProjects/QtAsp-Service/build-aspservice-Desktop_Qt_5_15_0_GCC_64bit-Debug/../src/Asp/aspobject.h:34: Fehler: multiple definition of `Asp2::print()'; main.o:/home/marc/QtProjects/QtAsp-Service/build-aspservice-Desktop_Qt_5_15_0_GCC_64bit-Debug/../src/Asp/aspobject.h:34: first defined here</p>
  </blockquote>
  <p>This this possible in general? If yes, what is wrong.</p>