求找错误啊
#include<iostream>using namespace std;
class container{
protected:
double radius;
double height;
public:
container(double ra)
{container::radius=ra;}
double print_ra()
{return height;}
virtual double surface_area()=0;
virtual double volume()=0;
};
class sphere:public container{public:
sphere(double ra):container(ra)
{}
double surface_area()
{return 4*3.1416*radius*radius;}
double volume(){return 3.1416*radius*radius*radius*4/3
};
class cylinder:public container{
public:
cylinder(double ra,double he):container(ra)//C:\Microsoft Visual Studio\MyProjects\h1\z1.cpp(26) : error C2969: syntax error : ';' : expected member function definition to end with '}'
{height=he;
}
double volume(){
{return 3.1416*radius*radius*height;}
};
class cube:public container{
public:
cube(double ra):container(ra){};
double surface_area()
{return radius*radius*6;}
double volume()
{return radius*radius*radius;}
};
int main()
{ container *ptr;
sphere obj1(8);
cylinder obj2(3,5);
cube obj3(5);
ptr=&obj1;
cout<<"球体半径:"<<ptr->print_ra()<<endl;
cout<<"求体表面积: "<<ptr->surface_area()<<endl;
cout<<"球体体积:"<<ptr->volume()<<endl;
ptr=&obj2;
cout<<"圆柱体半径:"<<ptr->print_ra()<<endl;
cout<<"圆柱体高:"<<ptr->print_he()<<endl;
cout<<"圆柱体表面积:"<<ptr->surface_area()<<endl;
cout<<"圆柱体体积:"<<ptr->volume()<<endl;
ptr=&obj3;
cout<<"正方体边长:"<<ptr->print_ra()<<endl;
cout<<"正方体表面积:"<<ptr->surface_area()<<endl;
cout<<"正方体体积:"<<ptr->volume()<<endl;//C:\Microsoft Visual Studio\MyProjects\h1\z1.cpp(63) : fatal error C1004: unexpected end of file found
return 0;
}