这是因为01的带参数构造函数把默认不带参数的构造函数Overloading了,而03的构造函数没有调用带参的01构造函数,所以出错,
在03构造函数里面加上 super(int r,String s),可以了。

解决方案 »

  1.   

    abstract class Glyph    相当于把 Glyph 抽象出来.
     
    class RoundGlyph03 extends RoundGlyph01   RoundGlyph01也是继承 Glyph. 楼主可以试一下把 RoundGlyph01 abstract一下  你就知道为啥了
      

  2.   

    RoundGlyph03(int r,String s) {
       radius = r;
       this.s = s;
       System.out.println("RoundGlyph03.RoundGlyph(),radius = "+radius+" "+s);
      }
    在RoundGlyph03 类的构造函数中,如果不显式的调用其继承类的构造函数的话,
    系统默认在RoundGlyph03 类的构造函数中调用继承类无参数构造函数即:
    RoundGlyph01(), 而类RoundGlyph01还没有定义无参数构造函数,所以就报错了。
    而继承抽象类Glyph就不一样了,其有无参数构造函数。
      

  3.   

    你可以如下修改:
      RoundGlyph03(int r,String s) {
       super(r, s);
       System.out.println("RoundGlyph03.RoundGlyph(),radius = "+radius+" "+s);
      }
      

  4.   

    你要明白这样一个道理,就是每个子类的构造方法必须调用父类的构造方法。
    如果你没有在你子类中写明调用父类的那个构造方法,就默认要调用没有参数的那个,
    这个时候,如果你的父类没有没有参数的构造方法,就会出错。
    class RoundGlyph03 extends RoundGlyph01 ,
    但是RoundGlyph01没有0参数的构造方法,所以出错。你可以选择帮RoundGlyph01 加一个0参数的构造方法,也可以像HawaiiLeo(罗马数字) 所说的那样,在RoundGlyph03指定调用父类的那个构造方法:  RoundGlyph03(int r,String s) {
       super(r, s);
       System.out.println("RoundGlyph03.RoundGlyph(),radius = "+radius+" "+s);
      }
      

  5.   

    Glyph类是抽象类抽象类是不可以继承的。
    怎么能继承抽象类呢?
      

  6.   

    简单,在函数:
    RoundGlyph03(int r,String s) {
       radius=r;
       this.s=s;
       System.out.println("RoundGlyph03.RoundGlyph(),radius="+radius+" "+s);
      }
    的第一句里加上super(r,s)就行了。你的父类没有默认构造函数,那么必须在子类构造函数的第一句中显示调用父类构造函数。
      

  7.   

    呵呵, maowu(猫呜) 已经说过了,没注意。sorry
      

  8.   

    基本概念不清,也能写出这样的程序.牛.
    ------------------------------------
    体验速度,体验CSDN新版论坛助手:http://community.csdn.net/Expert/TopicView.asp?id=3108679