2014-09-03 2 views
0

내가이 오류를 얻을 소속 카테고리 : 일부 인터넷 검색을 통해연결 오류의 vtable 정의와

Undefined      first referenced 
symbol        in file 
typeinfo for Operand    Expression_Tree.o 
vtable for Operand     Expression.o 

와 비슷한 질문을보고 나는 때문에 내가 특별히 생성자 (가상 함수를 처리하는 방법/소멸자의 아마 사실을 발견했습니다) in this

class Expression_Tree 
{ 
public: 
    virtual double   evaluate() = 0; 
    virtual std::string  get_postfix() const = 0; 
    virtual std::string  get_infix() const = 0; 
    virtual std::string  str() const = 0; 
    virtual void    print(std::ostream&, int hopCount = 0) const = 0; 
    virtual Expression_Tree* clone() const = 0; 

    virtual ~Expression_Tree(){} 
protected: 
    Expression_Tree() {} 
    Expression_Tree(const Expression_Tree& o) = delete; 
    Expression_Tree(Expression_Tree&&) = default; 
}; 

평범하지 않은 사람이 있습니까?

+0

자체를했다. 포함. 예. 부디. –

+0

@KerrekSB 나는 이것의 자체 포함 된 예제를 만들기 시작할 곳조차 모른다. –

+1

서브 클래스에 모든 순수 가상 함수를 정의했는지 확인하십시오. 컴파일러/링커에 따라 순수 가상 함수 재정의가 누락 된 경우 vtable은 자동으로 건너 뛰고 나중에 누락 된 것으로보고됩니다. – Quentin

답변

0

피할 수없는 것은 피할 수없는 피할 수없는 피할 수없는 피할 수없는 부분이다. 나는이 제거되면

class Operand : public Expression_Tree 
{ 
public: 
    Operand& operator=(const Operand&) = default; 
    Operand& operator=(Operand&&) = default; 
    // void print(std::ostream&, int hopCount = 0) const; <- this was the problem 
    std::string get_postfix() const; 
    std::string get_infix() const; 
    ~Operand() = default; 
    Operand(const Operand&) = default; 
    Operand(Operand&&) = default; 
protected: 
Operand() 
    : Expression_Tree() {} 
}; 

void print() 모든) =