This is code i have written to understand the concept. The code is fine and it runs.
What i dont understand is that why is the marked line needed ?
template <class T>
class D
{
    public :
    template <class P>  //<------------------Why is this needed ? --------------
    friend void print(D <P> obj);
};
template <class T>
void print(D<T> obj)
{std::cout<<sizeof(T);};
int main()
{
    D <char>obj3;
    print(obj3);
    return 0;
}
or in other words why does the following not run ?
template <class T>
class D
{
    public :
    friend void print(D <T> obj);
};
 
     
    
obj);` I think that must be a reason.