getsurface,还有getvolume函数应该怎么写?求大神帮忙解答,谢谢!!

 #include<iostream>
using namespace std;
class container{
   protected:   double radius;
   public:  container(double radiusl);
           virtual double surdface_area()=0;
           virtual double volume()=0;
};
class cube:public container{
public:
 cube(double l):container(l)
 {length=l;}
 double surdface_area()
 {return 6*length*length;}
 double volume()
 {return length*length*length;}
protected:
double length;
};
class spherre:public container{
public:
 spherre(double r):container(r)
 {Radius=r;}
 double surdface_area()
 {return 4*3.14*Radius*Radius;}
 double volume()
 {return 4/3*3.14*Radius*Radius;}
protected:
 double Radius;
};
class cylinder:public container{
public:
 cylinder(double r,double h):container(r)
 {Radius=r;
 High=h;
 }
double surdface_area()
{return 2*3.14*Radius*Radius+2*3.14*Radius*High;}
 double volume()
 {return 3.14*Radius*Radius*High;}
protected:
 double Radius;
 double High;
};
void getSurface_area()
{
}
void getVolume()
{
}
void main ()
{
 container *p[3];
p[0]= new cube(6); p[1]=new spherre (5);  p[2]=new cylinder(5,6);
for (int i=0;i<3;i++)
cout<<"表面积为"<<getSurface_area(p[i])
<<",体积为"<<getVolume(p[i])<<endl;
}

问题是:'getVolume' : function does not take 1 parameters

error C2660: 'getSurface_area' : function does not take 1 parameters

 

someOne_forward
浏览 1920回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP