小编Tom*_*rov的帖子

错误:无法将std :: ostream左值绑定到std :: basic_ostream <char> &&

之前在Overloading operator <<遇到过这个问题:无法将lvalue绑定到'std :: basic_ostream <char> &&',以下代码导致:

error: cannot bind ‘std::ostream {aka std::basic_ostream<char>}’ lvalue to ‘std::basic_ostream<char>&&’
Run Code Online (Sandbox Code Playgroud)

和代码:

// tried forward declaring but this did not help
namespace Tree {
    template<typename> class Node;
};
template<typename T> std::ostream& operator<<(std::ostream&, const Tree::Node<T>&);

namespace Tree {
    template<typename> class Tree;

    template<typename T>
    class Node {
        friend inline std::ostream& operator<<(std::ostream& out, const Node& node) {
            return out << node.getData();
        }
        friend class Tree<T>;
        // member declarations
        ...
    };

    template<typename T> …
Run Code Online (Sandbox Code Playgroud)

c++

2
推荐指数
1
解决办法
7045
查看次数

标签 统计

c++ ×1