title: C++: Overload << Operator with templates
body: <p>Unfornately I couldn't find a post regarding my following problem.
  I want to write a litte class which overloads the &lt;&lt;-Operator to get
  variable types of data using templates. The .h-file of my class looks like this:</p>
  
  <pre><code>class MyClass {
  
      private:
         ...
  
      public:
          template &lt;typename&gt; void operator&lt;&lt;(T data);
  };
  </code></pre>
  
  <p>The CPP-file:</p>
  
  <pre><code>template &lt;typename T&gt; void MyClass::operator&lt;&lt;(T data) {
      ...
      return;
  }
  </code></pre>
  
  <p>Now I want to use my class:</p>
  
  <pre><code>MyClass mc;
  mc &lt;&lt; "Test";
  mc &lt;&lt; 123; 
  </code></pre>
  
  <p>But my gcc compiler won't compile it giving me following error message:</p>
  
  <pre><code>undefined reference to `void MyClass::operator&lt;&lt; &lt;char const*&gt;(char const*)'
  </code></pre>
  
  <p>or if i use int for example:</p>
  
  <pre><code>undefined reference to `void MyClass::operator&lt;&lt; &lt;int&gt;(int)'
  </code></pre>
  
  <p>What am I doing wrong??? Can Someone help me?</p>