菜鸟新学C++,问题求教
刚开始学,没人教自己看书真的问题多多呢,才写20行代码就出错,请高手指教
#include <iostream>
using namespace std;
template <class Type>
class term{
friend ostream & operator <<<Type>(ostream &,const term<Type> &);
private:
int col,row;
Type value;
public:
term(int x,int y,Type var):col(x),row(y),value(var){}
};
template <class Type> ostream & operator <<(ostream & out,const term<Type> & temp){
out<<"X:"<<temp.col<<" Y:"<<temp.row<<" Value:"<<temp.value<<endl;
return out;
};
int main(){
term<int> test(1,1,4);
cout<<test;
return 0;
}
friend里的template匹配不上,总报错,那应该如何写呢?