error: invalid new-expression of abstract class type 'Rectangle'

来源:互联网 发布:windows 10企业版激活 编辑:程序博客网 时间:2024/06/11 22:51
class GeometricObject {……virtual bool hit(const Ray& ray, double& t, ShadeRec& s) const = 0;……};


class Rectangle: public GeometricObject {};

Rectangle继承了GeometricObject,所以必须实现GeometricObject的纯虚函数hit()。

若在没有实现hit()的情况下就“new Rectangle”,就会报这个错误:“error: invalid new-expression of abstract class type 'Rectangle'”

4 0
原创粉丝点击