各位谁帮我做这题啊,还有30分钟要交卷啦,速度帮帮忙好么
c++吧
全部回复
仅看楼主
level 1
qulongjun 楼主
完善程序:(完成标注了“待实现”字样的函数,并调试程序至能正常运行。)
#include <iostream>
#include <cmath>
using namespace std;
const double PI=3.1415926;
class Geometric_shape{
     friend ostream & operator<<(ostream & os,Geometric_shape & gs){
         os<<"几何体"<<"周长:"<<gs.perimeter()<<"\n面积:"<<gs.area()<<"\n体积:"<<gs.volume();
         return os;
     }
public:
       virtual double perimeter()=0;
       virtual double area()=0;       
       virtual double volume()=0;           
};
class Circle :public Geometric_shape{
     friend ostream & operator<<(ostream & os,Circle & cir);   //待实现
public:
       Circle(){Radius = 0;}
       Circle(double);//待实现
       double perimeter();   //待实现
       double area(); //待实现           
       double volume();        //待实现
private:
       double Radius;
};
class Cylinder:public Circle {//圆柱
     friend ostream & operator<<(ostream & os,Cylinder & cyl);   //待实现
       double Height;
public:
       Cylinder(){Height=0;}
       Cylinder(double v,double h);//待实现
       double volume();//待实现      
};
class Cone: public Circle {//圆锥
     friend ostream & operator<<(ostream & os,Cone & cone);   //待实现  
     double Height;
public:
       Cone(){Height=0;}
       Cone(double v,double h);//待实现
       double volume();//待实现           
};
int main(){
       Geometric_shape * gs;
       Circle cc1(10);
       Cylinder cl1(10,3);
       Cone cn1(10,3);
       gs=&cc1;
       cout<<*gs<<endl;
       gs=&cl1;
       cout<<*gs<<endl;
       gs=&cn1;
       cout<<*gs<<endl;
       return 0;
}

2011年06月07日 03点06分 1
level 1
qulongjun 楼主
[88]
2011年06月07日 03点06分 2
level 11
交了没?
2011年06月07日 04点06分 3
level 12
[打酱油]
2011年06月07日 05点06分 5
level 1
LZV5,考试交卷还能上网?
居然还不是手机?
2011年06月07日 05点06分 6
level 8
应该形成长效机制
对发这种贴的实行惨无人道的围观
2011年06月07日 05点06分 7
level 10
必须的
2011年06月07日 05点06分 8
level 8
[Yeah]果断围观
2011年06月07日 05点06分 9
level 7
手机还能打出格式化的代码果然NB
2011年06月07日 05点06分 10
level 10
继续围观
2011年06月07日 05点06分 11
level 7
[汗] 同情LZ……
2011年06月07日 05点06分 12
1