找不到功能定义?

时间:2017-04-03 02:58:20

标签: c++ c++11 visual-c++

我正在尝试定义函数“getCurSize”,但由于某些原因,即使我在它下面定义它,它也不会识别定义并以绿色加下划线。 (初学者在这里耐心赞赏)

template<class ItemType>
class FDHPolynomial
{
private:
    FDHNode<ItemType>* headPtr;
    int itemcount;
    FDHNode<ItemType>* getPointedTo(const ItemType& nodenum) const;

public:
    FDHPolynomial();
    FDHPolynomial(const FDHPolynomial <ItemType>& aPoly);
    virtual ~FDHPolynomial();

    int getCurSize() const;
    bool isEmpty() const;
    bool add(const ItemType& newCoeffi, const ItemType& newExpon);
    bool remove(const ItemType& anExpon);
    void clear();
    bool contains(const ItemType& aExpon) const;
    ItemType degree() const;
    ItemType coefficient(const ItemType& power) const;
    void changeCoefficient(const ItemType& newCoeffi, const ItemType&power);
    std::vector<ItemType> toVector() const;

void print();


};

template<class ItemType>
int Polynomial<ItemType>::getCurSize() const
{
    return itemCount;
}

1 个答案:

答案 0 :(得分:3)

您的范围运算符(::)无法将Polynomial<ItemType>::getCurSize() const与声明的任何函数匹配,因为Polynomial不作为类存在。由于班级FDHPolynomial具有getCurSize() const功能,因此请将您的定义更改为:

template<class ItemType>
int FDHPolynomial<ItemType>::getCurSize() const {
    return itemCount;
}
相关问题