问题描述
- 有一个错误,大家帮忙看下
-
include
define PI 3.14
class shape
{
public:
virtual float area()=0;
virtual float girth()=0;
};
class circle:public shape
{
public:
circle(int a)
{
r=a;
}
float area()
{
s=PI*r*r;
return s;
}
float girth()
{
c=2*r*PI;
return c;
}
friend double operator + (circle &v,circle &d);
private:
int r;
float s,c;
};
double operator + (circle &q,circle &u)
{
return(q.area()+u.area());
}void mianji(shape&b)
{
cout<
}
void zhouchang(shape&c)
{
cout
}
void mianji(shape *d)
{
coutarea()<<endl;
{
void main()
{
circle q(5),u(6),s(0);
cout<<"圆1的面积"<<endl;
mianji(q);
cout<<"圆2的面积"<<endl;
mianji(u);
s=q+u;
mianji(s);
cout<<"圆的周长"<<endl;
zhouchang(q);}
时间: 2025-01-27 03:33:45