上次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
在把基类放在派生类之后就不会出现问题啦