-2
我創建了一個名爲Geometry
的類,根據提供給構造函數的參數數目來計算圓形,矩形或三角形的面積。構造函數分別接受1,2和3個參數。計算二維形狀的面積
#include<stdio.h>
#include<iostream>
#include<math.h>
using namespace std;
class Geometry
{
private:
int a,b,c,d,e,r;
float pi=3.14;
public:
void input()
{
cout<<"Enter the value of a,b,c,d,r";
cin>>a;
cin>>b;
cin>>c;
cin>>d;
cin>>e;
cin>>r;
}
void calculate();
void display();
Geometry (int);
Geometry (int,int);
Geometry (int,int,int);
};
Geometry :: Geometry(int p)
{
p=r;
float pi=3.14;
}
Geometry :: Geometry (int x,int y)
{
x=a,y=b;
}
Geometry :: Geometry (int f,int g,int h)
{
f=c,g=d,h=e;
}
void calculate()
{
int a,b,c,d,e,r;
float s;
s=(c+d+e)/2;
float areat,areac,arear;
areat=sqrt(s*(s-c)*(s-d)*(s-e));
arear=(a*b);
areac=(3.14*r*r);
}
void display()
{
float areac,areat,arear;
cout<<"area of circle is:"<<areac;
cout<<"area of rectangle is:"<<arear;
cout<<"area of triangle is:"<<areat;
}
int main()
{
Geometry z;
z.calculate();
z.display();
getch();
}
我收到的錯誤是:
排隊呼叫幾何不匹配函數::幾何()預計59
和
候選人第33行提供的2個參數
這些是什麼意思,我該如何解決這些錯誤?