我试图重载<<运算符,但我得到以下错误:
错误:'std :: cout <<"Test"'中'operator <<'的模糊重载
..跟随50亿其他类似的错误:
c:\ mingw\bin ../ lib/gcc/mingw32/4.5.2/include/c ++/ostream:165:7:注意:候选人是:...
这是因为我在main.cpp文件中使用cout.
这是我的代码:
在BinTree.h中:
template <typename T>
class BinTree{
...
friend std::ostream& operator<< <>(std::ostream&, const T&);
Run Code Online (Sandbox Code Playgroud)
在BinTree.cpp中:
template <typename T>
std::ostream& operator<< (std:: ostream& o, const T& value){
return o << value;
}
Run Code Online (Sandbox Code Playgroud)
在此先感谢您提供任何帮助.