报错83 1 C:\Users\王淑婧\Desktop\c.5_4.cpp [Note] candidate expects 1 argument, 0 provided#include<iostream> #include<iomanip> using namespace std; class point{ private: int x,y; public: point(int xx,int yy){ x=xx;y=yy; } int getx(){return x;} int gety(){return y;} ~point(){ cout<<"Point xigou "<<x<<" "<<y<<endl; } point(point &p){ x=p.x; y=p.y; } }; class Ellipse{ private: point a,b; public: ~Ellipse(){ cout<<"Ellipse xigou "<<b.getx()<<" "<<b.gety()<<endl; } Ellipse(int x1,int x2,int x3,int x4):a(x1,x2),b(x3,x4) { cout<<"gouzao 1 "<<x1<<" "<<x2<<" "<<x3<<" "<<x4<<endl; } Ellipse(point &p1,point &p2){ a=p1;b=p2; cout<<"gouzao 2 "<<p1.getx()<<" "<<p1.gety()<<" "<<p2.getx()<<" "<<p2.gety()<<endl; } void show(){cout<<a.getx()<<" "<<a.gety()<<" "<<b.getx()<<" "<<b.gety()<<endl; } int Area(){ return 3.14*a.gety()*b.getx(); } }; int main(){ int a,b,c,d; cin>>a>>b>>c>>d; cin>>a>>b;cin>>c>>d; point p1(a,b),p2(c,d); Ellipse e1(a,b,c,d); e1.show(); Ellipse e2(p1,p2); e2.show(); cout<<fixed<<setprecision(4)<<e1.Area()<<endl; cout<<fixed<<setprecision(3)<<e2.Area()<<endl; return 0; }
时间: 2023-06-26 11:04:06 浏览: 167
tcpmp.src.0.72RC1.rar_tcpmp_tcpmp src_tcpmp 0.72 sour_tcpmp.src
这个代码报错的原因是在创建 Ellipse 类对象时,构造函数需要传入参数,但是你在创建 Ellipse 类对象的时候没有传入参数,导致编译器报错。你可以按照下面的方式修改代码:
1. 在创建 Ellipse 类对象时,传入构造函数所需的参数。
2. 在创建 Ellipse 类对象时,传入 point 类对象,且将参数改为引用类型。
修改后的代码如下:
阅读全文