c++题目有个错误不知道怎么回事#include#includeusing 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,
来源:学生作业帮助网 编辑:作业帮 时间:2024/08/30 08:58:02
![c++题目有个错误不知道怎么回事#include#includeusing 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,](/uploads/image/z/6988269-21-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%23include%23includeusing+namespace+std%3Bclass+Rectangle%7Bpublic%3ARectangle%28int+a1%2Cint+b1%2Cint+a2%2Cint+b2%29%3Bvoid+area%28int+a1%2Cint+b1%2Cint+a2%2Cint+b2%29%3Bvoid+output%28%29%3BRectangle%28%29%3Bprivate%3Aint+ar%3B%7D%3BRectangle%3A%3ARectangle%28int+a1%2C)
c++题目有个错误不知道怎么回事#include#includeusing 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,
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
c++题目有个错误不知道怎么回事#include#includeusing 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,
void area(int a1,int b1,int a2,int b2)//计算面积
{
ar=(-1)*(a1-a2)*(b1-b2);
}
这个函数是Rectangle类的一个成员函数,但是你的定义方法认为它是一个全局函数,所以不能识别类的私有变量
改成
void Rectangle::area(.)
{
}