C++ questions regards to redefinition error when implement a static member function template?
<p>I try to do implement a static function in cpp source file. Get <strong>redefinition error</strong>.
Can someone help me out? Thanks very much!</p>

<pre><code>DEFINE_MY_STATIC_PTR(B_type)
DEFINE_MY_STATIC_PTR(A_type)
</code></pre>

<p>-- error: redefinition </p>

<pre><code>struct A_type : B_type
{}

#define DEFINE_MY_STATIC_PTR( TYPE )\
  template&lt; typename TYPE &gt; \
  My_self_deleting* My_static_ptr&lt;TYPE&gt;::my_self_deleting_ptr( TYPE* ptr ) \
  {  return ptr; } 

template&lt;typename TYPE&gt; 
struct My_static_ptr : My_pointer 
{
    static My_self_deleting*    my_self_deleting_ptr   ( TYPE* );
}
</code></pre>

<p>How to do this kind of define properly?</p>

<p>From all the help, I found it should delete the template above. It will become implementation for each TYPE when use.</p>

<pre><code>#define DEFINE_MY_STATIC_PTR( TYPE )\
  My_self_deleting* My_static_ptr&lt;TYPE&gt;::my_self_deleting_ptr( TYPE* ptr ) \
  {  return ptr; } 

DEFINE_MY_STATIC_PTR(B_type)
          error: too few template-parameter-lists
</code></pre>

<p>Should I add something more to this macro define?</p>

<p>Yes, add template &lt;></p>

<pre><code>  #define DEFINE_MY_STATIC_PTR( TYPE )\
  template &lt;&gt;
  My_self_deleting* My_static_ptr&lt;TYPE&gt;::my_self_deleting_ptr( TYPE* ptr ) \
  {  return ptr; } 
</code></pre>
