| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 348 人关注过本帖
标题:急!! 请教!!!
只看楼主 加入收藏
狂啸之剑
Rank: 1
来 自:江苏
等 级:新手上路
帖 子:2
专家分:0
注 册:2008-6-9
收藏
 问题点数:0 回复次数:0 
急!! 请教!!!
[size=4][size=5] 本人刚接触出C++,遇到一个小 问题,请大侠帮助。不胜感激!!
以下是我编的一个简单的程序:
#include<iostream>
const PI = 3.1415;
using namespace std;

class Simple_circle
{
public:
    Simple_circle();    
    Simple_circle(double radius) { itsRadius = radius; }
    ~Simple_circle() {}
    double get_radius() const { return itsRadius; }
    void set_radius(double r) { itsRadius = r; }
    double get_area(const double& );
private:
    double itsRadius;
}

Simple_circle::Simple_circle():
itsRadius(5)
{
}

double Simple_circle::get_area(const double& radius)
{
    return PI*radius*radius;
}

int main()
{
    Simple_circle c1;

    cout << c1.get_radius() << endl;
    set_radius(5);
    cout << "The area is" << c1.get_area(c1.get_radius()) <<endl;

    return 0;
}


但是不能通过编译!!
给出三个error:
1.'Simple_circle::Simple_circle' : constructors not allowed a return type
2.'Simple_circle::Simple_circle' : error in function definition or declaration; function not called
3.'set_radius' : undeclared identifier


敬请各位高手指教,先谢谢了!!!
[/size][/size]
搜索更多相关主题的帖子: 不胜感激 private include public 
2008-06-10 22:10
快速回复:急!! 请教!!!
数据加载中...
 
   



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

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