//函數(shù)聲明部分friend ostream& operator<<<>(ostream&,SinglyList<T>&); //輸出單鏈表所有元素//函數(shù)定義template <class T>ostream& operator<<<>(ostream &out,SinglyList<T> &list){ out<<"("; for(Node<T> *next=list.head->next; next != NULL; next = next->next) { out<<next->data; if(next->next != NULL) out<<","; } out<<")\n"; return out;}g++ 編譯時報錯:SinglyList.h:64:55: 錯誤:模板標識符‘operator<< <>’出現(xiàn)在基本模板的聲明中 ostream& operator<<<>(ostream &out,SinglyList<T> &list)SinglyList.h:20:19: 錯誤:‘std::ostream& operator<<(std::ostream&, SinglyList<Computer>&)’的模板標識符‘operator<< <>’不匹配任何模板聲明 friend ostream& operator<<<>(ostream&,SinglyList<T>&); //輸出單鏈表所有元素 這是我在書上看到的代碼,在我的環(huán)境中編譯報錯。首先對于“operator<<<>”這部分中的<>不明白代表什么意思?先謝了。
- 1 回答
- 0 關注
- 819 瀏覽
添加回答
舉報
0/150
提交
取消