自考C++当中的一些问题啊

[复制链接]
查看11 | 回复2 | 2010-9-18 21:45:28 | 显示全部楼层 |阅读模式
#include
#include
#define PI 3.1415926
class Shape {
public:
virtual double Area( ) = 0;
};
class trapezoid :public Shape
{private :
double s,x,h;
public:
trapezoid(double a,double b,double c)
{s=a;

x=b;

h=c;

}
double Area(){
return (s+x)*h/2;
};
class Circle :public Shape
{private :

double R;

public :

Circle ( double r) {

R=r;

}


double Area (){

return PI*R*R ;}


};
class Triangle :public Shape
{ private :

double a,h;

public :

Triangle(double x,double y)

{a=x;

h=y;

}

double Area (){

return a*h/2;}



};
void main ()



{
Trapezoid A(3.3,5.5,6);

Shape &ra =A;

ca=ra.Area();

Circle B(3.4);

Shape &rb=B;

ba=rb.Area();

Triangle C(3.6,7.8);

ca=C.Area();

cout << "梯形的面积为:"<<ca<<"园的面积为:"<#include #define PI 3.1415926class Shape { public: virtual double Area( ) = 0;};class trapezoid:public Shape
回复

使用道具 举报

千问 | 2010-9-18 21:45:28 | 显示全部楼层
#include #include #define PI 3.1415926class Shape {public:virtual double Area( ) = 0;};class Trapezoid :public Shape{private : double s
回复

使用道具 举报

千问 | 2010-9-18 21:45:28 | 显示全部楼层
double Area(){ return (s+x)*h/2;少}
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行