oop = require("oop/oop") function Vault(cls) cls.setattr(cls, "public_note", nil, "public") cls.setattr(cls, "protected_note", nil, "protected") cls.setattr(cls, "private_note", nil, "private") cls.method("public_method", function(this) print("public_method:", this.public_note) end, "public") cls.method("protected_method", function(this) print("protected_method:", this.protected_note) end, "protected") cls.method("private_method", function(this) print("private_method:", this.private_note) end, "private") function cls.__init(this) this.public_note = "hello" this.protected_note = "shielded" this.private_note = "secret" end end function SubVault(cls) cls.inherit(Vault) function cls.show_all(this) print("inside SubVault:") this.public_method() this.protected_method() this.private_method() end end local v = oop.new(Vault) print("outside Vault:") print("public_note:", v.public_note) v.public_method() print("protected_note:", v.protected_note) print("private_note:", v.private_note) v.protected_method() v.private_method() local s = oop.new(SubVault) s.show_all()