#include<iostream>
#include<cmath>
using namespace std;
class Point
{
public:
Point(double x,double y){X = x;Y = y;}
Point(Point &p);
~Point(){}
double Getx() {return X;}
double Gety() {return Y;}
private:
double X;
double Y;
};
Point::Point(Point &p)
{
X = p.X;
Y = p.Y;
}
class Rectangle
{
public:
Rectangle(Point p1,Point p2);
Rectangle(Rectangle &p);
~Rectangle(){}
double Getarea(){return area;}
private:
Point q1;
Point q2;
double area;
};
Rectangle:: Rectangle (Point p1,Point p2):q1(p1),q2(p2)
{
double a;
a = double((q1.Getx())-(q2.Getx()));
double b ;
b = double((q1.Gety())-(q2.Gety()));
area = sqrt(a*a*b*b);
}
Rectangle::Rectangle(Rectangle &p)
{
area = p.area; //出错error C2512: 'Point' : no appropriate default constructor available
}
void main()
{
Point d1(1,0),d2(2,0);
Rectangle r1(d1,d2);
cout<<r1.Getarea<<endl;
}
[此贴子已经被作者于2007-10-29 17:38:39编辑过]