English 中文(简体)
AS3级职能范围
原标题:
  • 时间:2009-05-20 16:07:37
  •  标签:

如果我有2个班级,第一个学期延长,第二个班子如何能够从第一个班起起静态功能?


package p1 {
    class a {
        static function a1() {
            //do soemthing
        }
    }

    class b extends a {
        static function b1() {
            //do something else
        }
    }
}

a.a1(); // this works
b.a1(); // this doesn t work
b.b1(); //this works
最佳回答

当“B 延伸A”时,这实际上与“B类所有方法和特性”不同。 B类的物体不采用A类界定的所有财产和方法。 当你称之为静态方法或财产时,你处理的是类别而不是物体(与使用名称空间非常相似)。

ADDED: The only way solve your task is to override a1(args) in class B and to call super.a1(args) inside... 1 string of code. But it seems to me, that you have a software architect problem if it s not possible to avoid such kind of usage.

问题回答

使用超级手段指母方法。

super.b1();

EDIT:O,在研究你所写的内容时,我认为,你需要确定1个公共或受保护的范围。





相关问题
热门标签