2017-04-03 124 views
0

我试图定义函数“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; 
} 
+2

'多项式 :: getCurSize()' - >'FDHPolynomial :: getCurSize()' –

回答

3

你的范围操作符(::)无法比拟Polynomial<ItemType>::getCurSize() const以声明的功能,因为Polynomial不作为一个阶级存在。因为类FDHPolynomialgetCurSize() const功能,你的定义改成这样:

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

WOW WOW哇!我为此打了我自己的额头。谢谢你,这是问题。 – Student1860

+0

没问题的人:)很高兴帮助! – 0xDEFACED