作为初学者,在初次深入学习C++模板类的时候遇到一些问题,模板类的友元模板函数在类外部定义时出现各种问题。
经过实际尝试,最简单直观又粗暴的方法是在模板类内部声明模板友元函数时重新声明一个新的模板
template <typename T>
class Complex
{
template <typename G>
friend Complex<G> MySub(Complex<G> &c1,Complex<G> &c2);
template<class F>//
friend ostream &operator<<(ostream &out,Complex<F> &c3);
public:
Complex(<