有对xcode比较熟悉的么?帮忙看看这个错误提示

我就写了一个类,
.h

class Quote{
public:
    Quote();
    ~Quote();
    virtual double net_price(std::size_t n) const;
    void display();
private:
    std::string bookNo;
protected:
    double price = 0.0l;
};

.cpp


Quote::Quote(){
    
}
Quote::~Quote(){
    
}

void Quote::display(){
    
}

编译的时候就老提示这个错误,网上查说编译环境有问题,请问有人知道这个怎么处理吗?
macos10.9.2
xcode5.0.2

如果子类继承了父类但是没有实现父类的虚函数,就会报如上错误。同时,没有实现析构函数也会出现同样问题。

我这就写了一个类啊 没有继承啊

是不是如果一个类定义了虚函数 就必须要写一个子类来实现???
我这里只写了一个类,没有写子类 怎么就报错呢??

the first non-inline virtual member function has no definition
net_price函数定义下~

并不是你写了一个类有虚函数 就必须要写个子类来实现才能运行。如果楼主在.h里这样写的 virtual double net_price(std::size_t n) const{return 1;}ok可以继续运行的 想楼主那样写的要在cpp里进行实现的 如果你的父类写个纯虚函数那么一定要有个子类去继承并且实现出来

xiexie
问题找到了,我在cpp里面写实现的时候,方法名后面没加const