declaring a class member function as friend of a template class
<pre><code>#include&lt; iostream&gt;  
using namespace std;  

template&lt; class t&gt;  
class X  
{  
  private:  
      t x;    

  public:  
        template&lt; class u&gt;  
         friend u y::getx(X&lt; u&gt; ); 

      void setx(t s)  
      {x=s;}  
           };      

class y   
{  
 public:  
     template&lt; class t&gt;  
     t getx(X&lt; t&gt; d)  
     {return d.x;}     
};  

int main()  
{  
    X&lt; int&gt; x1;  
    x1.setx(7);  
    y y1;  
    cout&lt;&lt; y1.getx(x1);    
    return 0;  
}       
</code></pre>

<p>The above program, when compiled, showed an error that <code>y</code> is neither a function nor a member function, so it cannot be declared a friend. What is the way to include <code>getx</code> as a friend in <code>X</code>?</p>
