weixin_51734827
邢宇涵
2020-12-04 00:19

invalid use of‘Point::Point’什么意思

#include<iostream>
#include<cmath>
#define PI 3.1415
using namespace std;
class Point
{
    int x,y;
public:
    Point(){}
    Point(int xx,int yy)
    {
        x=xx;y=yy;
    }
    Point(Point &r)
    {
        x=r.x;
        y=r.y;
    }
    int GetX(){return x;}
    int GetY(){return y;}
    ~Point()
    {
        cout<<"Point xigou "<<x<<" "<<y<<endl;;
    }
};
class Ellipse
{
    Point a,b;
    double area;
public:
     void Area()//计算面积值
    {
        double m,n;
        int x1,y1,x2,y2;
        x1=a.GetX(),y1=a.GetY(),x2=b.GetX(),y2=b.GetY();
        m=double(fabs(x1-x2)/2);
        n=double(fabs(y1-y2)/2);
      //cout<<x1<<" "<<y1<<" "<<x2<<" "<<y2<<endl;
      area=PI*m*n;
      //cout<<r<<endl;
      //cout<<area;
      Ellipse::Showarea();
    }
    Ellipse(){}
    Ellipse(int X1,int Y1,int X2,int Y2)
    {
        a(X1,Y1),b(X2,Y2);
        cout<<"gouzao 1 "<<X1<<" "<<Y1<<" "<<X2<<" "<<Y2<<endl;;
    }
    Ellipse(Point &p1,Point &p2)
    {
        a=p1,b=p2;
        cout<<"gouzao 2 "<<a.GetX()<<" "<<a.GetY()<<" "<<b.GetX()<<" "<<b.GetY()<<endl;
    }
     void Show()//输出坐标
    {
        cout<<a.GetX()<<" "<<a.GetY()<<" "<<b.GetX()<<" "<<b.GetY()<<" "<<endl;
    }
    void Showarea()//输出面积值
    {
        cout<<area<<endl;;
    }
    ~Ellipse()
    {
        cout<<"Ellipse xigou "<<b.GetX()<<" "<<b.GetY()<<endl;
    }

};


int main()
{
    int X1,X2,Y1,Y2;
    cin>>X1>>Y1>>X2>>Y2;
    //cout<<X1<<" "<<Y1<<" "<<X2<<" "<<Y2<<endl;
    Ellipse e1(X1,Y1,X2,Y2);
    int X3,Y3,X4,Y4;
    cin>>X3>>Y3>>X4>>Y4;
    Point p1(X3,Y3),p2(X4,Y4);//构建对象1
    Ellipse e2(p1,p2);
    e1.Show();
    e2.Show();
    e1.Area();
    e2.Area();
    return 0;
}

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

相关推荐