87,910
社区成员
发帖
与我相关
我的任务
分享
function CBaseClass()
{
this.foo = function(){ alert( 'this is baseclass foo' ); };
this.foo1 = function() { alert( ' this is baseclass foo1' ); };
}
function CSubClass()
{
this.sup = new CBaseClass();
// this.super();
this.foo() = function()
{
this.sup.foo();//调用父类的函数,再处理本类的函数
alert( 'this is subclass foo' );
}
this.foo1=this.sup.foo1;
}
function main()
{
var obj = new CSubclass();
obj.foo();//调用了子类的foo
obj.foo1();//调用了父类的foo1
}