c++题目有个错误不知道怎么回事
来源:学生作业帮 编辑:搜搜考试网作业帮 分类:综合作业 时间:2024/07/28 07:00:19
c++题目有个错误不知道怎么回事
#include
#include
using namespace std;
class Rectangle
{
public:
Rectangle(int a1,int b1,int a2,int b2);
void area(int a1,int b1,int a2,int b2);
void output();
Rectangle();
private:
int ar;
};
Rectangle::Rectangle(int a1,int b1,int a2,int b2)
{
}
void area(int a1,int b1,int a2,int b2)//计算面积
{
ar=(-1)*(a1-a2)*(b1-b2);
}
void Rectangle::output()
{
cout
#include
#include
using namespace std;
class Rectangle
{
public:
Rectangle(int a1,int b1,int a2,int b2);
void area(int a1,int b1,int a2,int b2);
void output();
Rectangle();
private:
int ar;
};
Rectangle::Rectangle(int a1,int b1,int a2,int b2)
{
}
void area(int a1,int b1,int a2,int b2)//计算面积
{
ar=(-1)*(a1-a2)*(b1-b2);
}
void Rectangle::output()
{
cout
![c++题目有个错误不知道怎么回事](/uploads/image/z/10956249-9-9.jpg?t=c%2B%2B%E9%A2%98%E7%9B%AE%E6%9C%89%E4%B8%AA%E9%94%99%E8%AF%AF%E4%B8%8D%E7%9F%A5%E9%81%93%E6%80%8E%E4%B9%88%E5%9B%9E%E4%BA%8B)
void area(int a1,int b1,int a2,int b2)//计算面积
{
ar=(-1)*(a1-a2)*(b1-b2);
}
这个函数是Rectangle类的一个成员函数,但是你的定义方法认为它是一个全局函数,所以不能识别类的私有变量
改成
void Rectangle::area(.)
{
}
{
ar=(-1)*(a1-a2)*(b1-b2);
}
这个函数是Rectangle类的一个成员函数,但是你的定义方法认为它是一个全局函数,所以不能识别类的私有变量
改成
void Rectangle::area(.)
{
}