小编Tej*_*san的帖子

对继承函数的未定义引用

我正在实现 A* 算法来解决几个问题 - 8 Puzzle 问题和另一个问题。对于 A Star,我在 A_star.hpp 中实现了三个通用类:

template <class U>
class Heuristic{
public:
    virtual int getHeuristic(Node<U> currNode, Node<U> target);
};

template <class V>
class NextNodeGenerator{
public:
    virtual vector<pair<V, int> > generate(Node<V> curr);
};

template <class W>
class CompareVal{
public:
    virtual bool compare(W val1, W val2);
};
Run Code Online (Sandbox Code Playgroud)

为了解决 8 Puzzle 问题,我在 prob2.cpp 中为上述每个通用类实现了三个子类:

template <class hT>
class PuzzleHeuristic: public Heuristic<hT>{
public:
    virtual int getHeuristic(Node<hT> currNode, Node<hT> target){
        //Code for getHeuristic
    }
};

template <class cT>
class PuzzleCompareVal: …
Run Code Online (Sandbox Code Playgroud)

c++ inheritance templates

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

标签 统计

c++ ×1

inheritance ×1

templates ×1