C ++继承和覆盖

时间:2015-01-06 16:31:04

标签: c++ inheritance overloading

我不明白为什么以下代码无法编译(它是独立的:您可以复制/粘贴它):

#include <iostream>

struct Point
{
  float x, y;
};

class Base
{
public:

  virtual bool is_point_inside(float x, float y) const = 0;
          bool is_point_inside(const Point & p ) const { return is_point_inside(p.x, p.y); }
};

class Derived : public Base
{
public:

  bool is_point_inside(float x, float y) const override { return true; }
};

int main(int argc, char ** argv)
{
  Derived d;

  Point p;
  std::cout << d.is_point_inside(p);

  return 0;
}

有没有人有解释?

0 个答案:

没有答案