我不明白为什么以下代码无法编译(它是独立的:您可以复制/粘贴它):
#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;
}
有没有人有解释?