Java 我有一个儿童物体,继承基质。 我正试图从一个儿童物体内传出一个基级功能,但我正在发现一个错误,说这一功能不存在。
www.un.org/Depts/DGACM/index_spanish.htm 您能告诉我,我如何从儿童班级中讲基班功能?
function BaseClass()
{
this.render = function()
{
alert("BaseClass::render()");
}
}
function ChildClass()
{
this.render = function()
{
alert("BaseClass::render()");
// Now to CALL the base class render() function
this.baseRender = BaseClass.prototype.render;
this.baseRender(); // I get the error: "The function this.BaseRender() does not exist"
}
}
ChildClass.prototype = new BaseClass(); // inherit from BaseClass
ChildClass.prototype.constructor = ChildClass; // put the correct constructor reference back (not essential)