不要怂,就是干,撸起袖子干!

Commit a74e5574 by Sascha Depold

a method for proper inheritance

1 parent 927f4f84
Showing with 16 additions and 0 deletions
...@@ -155,6 +155,22 @@ var Utils = module.exports = { ...@@ -155,6 +155,22 @@ var Utils = module.exports = {
} else { } else {
return hash return hash
} }
},
inherit: function(subClass, superClass) {
if (superClass.constructor == Function) {
// Normal Inheritance
subClass.prototype = new superClass();
subClass.prototype.constructor = subClass;
subClass.prototype.parent = superClass.prototype;
} else {
// Pure Virtual Inheritance
subClass.prototype = superClass;
subClass.prototype.constructor = subClass;
subClass.prototype.parent = superClass;
}
return subClass;
} }
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!