为什么编译器显示未找到相关问题,但我的程序就是运行不出来
请指正错误的地方
#include<iostream>
#include<cmath>
using namespace std;
class point {
public:
point();
point(int xx, int yy) :x(xx), y(yy) {}
point(point& p) { x = p.x, y = p.y; }
friend class Rectangle; //运用友元函数求解
private:
int x, y;
};
class Rectangle {
private:
int chang, kuan;
public:
point p1;point p2;
Rectangle(point &p1, point &p2)
:chang(abs(p1.x - p2.x)), kuan(abs(p1.y - p2.y)) {
cout << "构造函数被调用" << endl;
}
Rectangle();
int area() { return (chang * kuan); }
};
int main()
{
point p1(1, 3);
point p2(2, 6);
Rectangle r(p1,p2);
cout << "运用友元类的结果:" << r.area();
return 0;
}