没有实现虚函数

Dan*_* Dv -3 c++ inheritance abstract-class virtual-functions

我想问一下,没有实现虚函数有问题吗?例如:

class Function { 
public: 
    virtual ~Function() {} 
    virtual double value(double x) const = 0; 
    virtual Function* clone() const = 0; 
protected: 
    virtual void print(ostream& os) const = 0; 
    friend ostream& operator<<(ostream& os, const Function& f); 
}; 
Run Code Online (Sandbox Code Playgroud)

在Function的派生类中,如果没有实现clone,它会给出编译错误吗?或者,如果我尝试调用derived.clone(),它会是运行时错误吗?

Fre*_*son 6

如果尝试实例化具有未实现的纯虚函数(包括继承的)的类,则会出现编译错误.