为什么vc++输入输出符重载用不了友元
本人一直都用borland, 前一阵子发现vc++无法用输出输入符重载, 后来发现原来是无法识别友元,程序如下:
template <class T>
class list{
public:
…………
friend ostream& operator<< (ostream& os, const list<T>& value){
for(node<T>* p=value.head->next; p!=NULL; p=p->next){
os<<p->data<<"->";
}
os<<"NULL";
return os;
}
protected:
node<T> *head;
};
在borland下可以调用输出符重载友元函数,但在vc++下却会报错,为什么呢??