问题描述:
这是我在用QT写画板大作业的时候遇到的:
non-static member ‘setType’ found in multiple base-class subobjects of type ‘Shape’:…
它说我重复定义原因是因为多个基类继承导致成员名重复
class Shape
{
public:
...
QString getType();
QPen getPen();
QList<QPoint> m_PointList;
bool m_bIsSelect;
QPoint start; // 初始
QPoint end;
...
};
class Circle : public Shape //圆
{
public:
Circle();
void paint(QPainter * painter); //绘画
void initPoints(QPoint point);
QPoint getShapeCenter();
void moveToPoint(QPoint point);
};
class Rect : public Shape //矩形
{
public:
Rect();
void initPoints(QPoint point);
void paint(QPainter * painter);
QPoint getShapeCenter();
void moveToPoint(QPoint point);
};
//画一个组合图形 矩形内画个圆
class RectCircle: public Rect,public Circle
{
public:
RectCircle();
void initPoints(QPoint point);
void paint(QPainter * painter); //绘图
QPoint getShapeCenter();
void moveToPoint(QPoint point); //移动图形
};
这一堆error看的我好揪心!!!
解决方案:域名指定
我在公有的变量指定了一个基类,问题完美解决
参考链接
https://blog.csdn.net/qq_24890953/article/details/104110050