C++ C++;隐式声明的编译器错误定义
大家好,今天我的代码是anissue。我创建了一个计算正方形、圆形和矩形面积的程序。具有形状的基类。其中,UML将shape作为抽象类,带有public area():double、getName():string和getDimensions:string,从shape派生的矩形具有受保护的高度和宽度,以及一个公共矩形(h:double、w:double),然后是从矩形派生的正方形,只有一个公共正方形(h:double),最后是一个圆,它由一个具有私有半径的形状导出,还有一个公共圆(r:double)。 到目前为止,我在shape.cpp文件的代码中已经走了很长的路,但在第10行我遇到了一个错误,上面写着shape.cpp:10:error:隐式声明的“constexpr shape::shape()”的定义 shape::shape() 以下是指向我的完整代码的链接: shape.cpp文件:C++ C++;隐式声明的编译器错误定义,c++,qt,compiler-errors,C++,Qt,Compiler Errors,大家好,今天我的代码是anissue。我创建了一个计算正方形、圆形和矩形面积的程序。具有形状的基类。其中,UML将shape作为抽象类,带有public area():double、getName():string和getDimensions:string,从shape派生的矩形具有受保护的高度和宽度,以及一个公共矩形(h:double、w:double),然后是从矩形派生的正方形,只有一个公共正方形(h:double),最后是一个圆,它由一个具有私有半径的形状导出,还有一个公共圆(r:doub
#include "shape.h"
#include "circle.h"
#include "rectangle.h"
#include "square.h"
#include <QDebug>
#include <QString>
#include <iostream>
using namespace std;
shape::shape()
{
};
#包括“shape.h”
#包括“circle.h”
#包括“矩形.h”
#包括“square.h”
#包括
#包括
#包括
使用名称空间std;
shape::shape()
{
};
非常感谢您的帮助您需要向类声明中添加
shape()
构造函数,如下所示:
#ifndef SHAPE_H
#define SHAPE_H
#include <QString>
#include <QDebug>
using namespace std;
class shape
{
public:
shape();
virtual double area()=0;
virtual QString getName()=0;
virtual QString getDimensions()=0;
virtual~shape(){}
};
#endif
shape::shape()
{
}
结尾没有分号。您需要向类声明中添加
shape()
构造函数,如下所示:
#ifndef SHAPE_H
#define SHAPE_H
#include <QString>
#include <QDebug>
using namespace std;
class shape
{
public:
shape();
virtual double area()=0;
virtual QString getName()=0;
virtual QString getDimensions()=0;
virtual~shape(){}
};
#endif
shape::shape()
{
}
结尾没有分号。您需要向类声明中添加
shape()
构造函数,如下所示:
#ifndef SHAPE_H
#define SHAPE_H
#include <QString>
#include <QDebug>
using namespace std;
class shape
{
public:
shape();
virtual double area()=0;
virtual QString getName()=0;
virtual QString getDimensions()=0;
virtual~shape(){}
};
#endif
shape::shape()
{
}
结尾没有分号。您需要向类声明中添加
shape()
构造函数,如下所示:
#ifndef SHAPE_H
#define SHAPE_H
#include <QString>
#include <QDebug>
using namespace std;
class shape
{
public:
shape();
virtual double area()=0;
virtual QString getName()=0;
virtual QString getDimensions()=0;
virtual~shape(){}
};
#endif
shape::shape()
{
}
结尾没有分号。您没有在
shape
类定义中声明shape
构造函数。整个矩形.cpp正在重新声明其标题?谢谢你们,我做了建议的更改,现在在shape.cpp的第10行出现了一个错误,显示重新定义shape::shapeshape
类定义中的构造函数shape
整个矩形.cpp正在重新定义其标题?谢谢你们,我做了建议的更改,现在在shape.cpp的第10行得到一个错误,说是重新定义shape::shape。你还没有在shape
中声明构造函数类定义。整条矩形.cpp正在重新定义其标题?谢谢你们。我做了建议的更改,现在在shape.cpp的第10行出现了一个错误,显示重新定义shape::shape。您尚未在shape
类定义中声明shape
构造函数。整条矩形.cpp正在重新定义其标题页眉?谢谢你们,我做了建议的修改,现在我得到一个错误,在shape.cpp的第10行显示了shape::shape的重新定义。好的,我继续,删除了上面的分号,并更正了我的形状。h,现在读作如下。好的,我继续,删除了上面的分号,并更正了我的形状。h,就是这样现在读作follows好的,我继续,删除了上面的分号,我更正了我的形状。h,现在读作follows好的,我继续,删除了上面的分号,我更正了我的形状。h,现在读作如下