| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1056 人关注过本帖
标题:这样的继承有错吗?不懂
只看楼主 加入收藏
victory623
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2008-12-8
收藏
 问题点数:0 回复次数:2 
这样的继承有错吗?不懂
class round{
    double x,y,r;
    round(double x,double y,double r){
        this.x=x;
        this.y=y;
        this.r=r;
    }
    double zc(){
        return (2*3.14159*r);
    }
    double mj(){
        return (3.14159*r*r);
    }
}

class column extends round{
    double h;
    column(int x,int y,int r,int h){
        this.x=x;
        this.y=y;
        this.r=r;
        this.h=h;
    }
    double mj(){
        return (2*3.14159*r*h);
    }
    double tj(){
        return (3.14159*r*r*h);
    }
}
为什么在column构造函数处提示Implicit super constructor round() is undefined. Must explicitly invoke another constructor
搜索更多相关主题的帖子: 继承 
2008-12-15 11:07
hwpayg
Rank: 2
等 级:论坛游民
帖 子:108
专家分:25
注 册:2008-4-3
收藏
得分:0 
父类中要定义一个无参构造函数吧
2008-12-15 13:15
Ethip
Rank: 5Rank: 5
等 级:贵宾
威 望:15
帖 子:771
专家分:0
注 册:2008-1-18
收藏
得分:0 
column(int x,int y,int r,int h){
        this.x=x;
        this.y=y;
        this.r=r;
        this.h=h;
    }

改成下面的试试
 column(int x,int y,int r,int h){
        super(x,y,z);
        this.h=h;
    }
2008-12-15 14:57
快速回复:这样的继承有错吗?不懂
数据加载中...
 
   



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

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