标签:style blog class code java ext
class Parent constructor: -> _privateAttr = ‘privateAttr‘ _privateFun = ()-> console.log "Parent::privateFun log #{_privateAttr}" publicAttr: ‘publicAttr‘ publicFun: ()-> _privateFun() console.log "Parent::publicFun log #{@publicAttr} #{_privateAttr}" @staticAttr: ‘staticAttr‘ @staticFun: ()-> console.log "Parent::staticFun log #{@staticAttr}" class Child extends Parent childPublicFun: ()-> try _privateFun()#报错 TypeError:Object #<Parent> has no method ‘_privateFun‘ catch e console.log "_privateFun() is error" console.log "Child::childPublicFun" p = new Parent c = new Child Parent.staticFun() #Parent::staticFun log staticAttr try p.staticFun()#报错 TypeError:Object #<Parent> has no method ‘staticFun‘ catch e console.log "p.staticFun() is error" p.publicFun() #Parent::privateFun log privateAttr #Parent::publicFun log publicAttr privateAttr try p._privateFun()#报错 TypeError:Object #<Parent> has no method ‘_privateFun‘ catch e console.log "p._privateFun() is error" Child.staticFun() #Parent::staticFun log staticAttr c.publicFun() #Parent::privateFun log privateAttr #Parent::publicFun log publicAttr privateAttr c.childPublicFun() #_privateFun() is error #Child::childPublicFun
coffeescript 继承、私有方法、私有属性、公共方法、公共属性、静态方法、静态属性实现,布布扣,bubuko.com
coffeescript 继承、私有方法、私有属性、公共方法、公共属性、静态方法、静态属性实现
标签:style blog class code java ext
原文地址:http://www.cnblogs.com/hbxeagle/p/3719300.html