4

これは私のクラスの選択です

template <typename TValue, typename TPred = std::less<TValue> >
class BinarySearchTree {
public:
BinarySearchTree<TValue, TPred> &operator=(BinarySearchTree<TValue, TPred> const &tree) {
    if (this != &tree) {
        tree.VisitInOrder(Insert);
    }
    return *this;
}
bool Insert(TValue const &value) {
    return m_Insert(value, pRoot);
}
template <typename TVisitor> void VisitInOrder(TVisitor visitor) const;
...
};

そして、次のシーケンスは機能しません:VisitInOrder(Insert)コンパイラが引数が欠落していると言っているからです

しかし、私のメインは次のようになり、引数なしで関数を使用できます。

void Print(int const x) { cout << x << endl; }

int main() {
    BinarySearchTree<int> obj1, obj2, obj3;
    obj1.Insert(10);
    obj1.VisitInOrder(Print);
    return 0;
}

完全なコードはこちら: http://pastebin.com/TJmAGwdu

4

1 に答える 1