关于C++编程vs2017 error: c2228的一种可能,或称基类位于派生类之后会出现的问题

上次C++实验编程遇到了一次error: c2228的问题,百度过了也没有答案,最终调换了基类和派生类的顺序才得到解决。

下面是产生异常的一段代码(以上省略基类Plane和其纯虚函数area和girth):

class Triangle: public Point, public Plane
{
public:
 Triangle(){}
 Triangle(float a, float b, float c, float d, float e, float f) : A(a, b), B(c, d), C(e, f) {}
 virtual float area() const;
 virtual float girth() const;
private:
 Point A;
 Point B;
 Point C;
};
class Point
{
public:
 Point(float = 0, float = 0);
 float x;
 float y;
};
这段代码就会出现error: c2228

在把基类放在派生类之后就不会出现问题啦

你可能感兴趣的:(关于C++编程vs2017 error: c2228的一种可能,或称基类位于派生类之后会出现的问题)