template<typename T> class Code; //友元函数的声明; template<typename T> ostream& operator<< (ostream& out, Code<T>&code); template<typename T> class Code { public: friend ostream& operator << <T>(ostream& out, const Code<T>&code); Code() {} Code(T data_, Vector<int>& code_) :data(data_), code(code_) {} T data; Vector<int>code; }; //友元函数的实现; template<typename T> ostream& operator<<(ostream& out,const Code<T>&code) { cout << "data: " << code.data << endl; return out; }
错误提示: