| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 650 人关注过本帖
标题:求找错误啊
取消只看楼主 加入收藏
guanling199
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2012-3-4
结帖率:0
收藏
已结贴  问题点数:20 回复次数:0 
求找错误啊
#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;
}
搜索更多相关主题的帖子: double class include public return 
2012-03-15 09:54
快速回复:求找错误啊
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016344 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved