--使用table封装面向对象
beauty={name = " "}
--封装对象方法
function beauty.init(self, name)
print("十八年前的一天王小丫出生")
self.name= name
end
--一般使用下面这种形式
function beauty:init( name)
print("十八年前的一天王小丫出生")
self.name= name
end
girl = beauty
women = beauty

beauty= nil

women:init("芙蓉姐姐")
girl:init("赛如花")
print(girl.name)
print(women.name)
--print(beauty.name)
--beauty.talk();
--print(beauty.name)

lua-table面向对象的更多相关文章

  1. lua table面向对象扩展

    一 .table扩展 -- 返回table大小 table.size = function(t) local count = 0 for _ in pairs(t) do count = count ...

  2. Lua 之面向对象编程

    Lua 之面向对象编程 Lua并不是为面向对象而设计的一种语言,因此,仅从原生态语法上并不直接支持面向对象编程,但Lua的设计中仍然包含了很多面向对象的思想,理解它们也更有助于理解Lua自身的一些高级 ...

  3. lua table integer index 特性

    table.maxn (table) Returns the largest positive numerical index of the given table, or zero if the t ...

  4. 树形打印lua table表

    为方便调试lua程序,往往想以树的形式打印出一个table,以观其表内数据.以下罗列了三种种关于树形打印lua table的方法;法一 local print = print local tconca ...

  5. lua table 排序--满足多条件排序

    前提 假设 一个小怪 有三种属性,等级(level).品质(quality).id(pid) 我们需要对他们进行排序,两种排序情况,第一是单一属性排序,比如按照等级进行排序,或者多种属性进行优先级排序 ...

  6. cocos2d-x lua table数据存储

    cocos2d-x lua table数据存储 version: cocos2d-x 3.6 1. 将table转为json http://blog.csdn.net/songcf_faith/art ...

  7. cocos2d-x lua table与json的转换

    cocos2d-x lua table与json的转换 version: cocos2d-x 3.6 1.引入json库 require("src/cocos/cocos2d/json&qu ...

  8. Lua table使用

    days = {"Sunday", "Monday", "Tuesday", "Wednesday", "Th ...

  9. lua table表

    lua table表 语法结构 创建一个 table 直接使用 "{}" 即可 table1 = {} -- 赋值 table1["name"] = " ...

  10. lua table表判断是否为空

    官方手册里早已经给了答案,那就是靠lua内置的next函数 即如此用: a = {} if next(a) == nil then next其实就是pairs遍历table时用来取下一个内容的函数. ...

随机推荐

  1. JavaWeb中的Servlet

    Servlet 目录 Servlet 一.互联网中的资源 二.Servlet 2.1.Servlet的作用 2.2.Servlet执行流程 2.3.Servlet生命周期 2.4.Servlet的继承 ...

  2. 红米手机刷 LineageOS (实操)

    参考:https://miuiver.com/how-to-flash-lineageos/ 实操机型:红米note8 1. 下载Android Platform-Tools 2. 下载对应机型的TW ...

  3. TouchableOpacity无效

    错误代码如下: <TouchableOpacity onPress={this.handleConfirmPress} activeOpacity={0.6} > <Text sty ...

  4. WGCMS 奇迹网站系统 介绍[V2023.2.2]

    智鹏网站系统,请勿用作非法用途 权利和义务: 程序仅限学习技术使用,未经官方许可不得用于商业! 程序售价500元一套,绑定域名,不限制端口.如绑定:xx.com,则www.xx.com.mu.xx.c ...

  5. HttpProxyCacheServer (音视频缓存框架)

    implementation 'com.danikula:videocache:2.7.0' //包 MyApplication 中: //音视频缓存框架private HttpProxyCacheS ...

  6. C#导出Excel设置单元格样式

    C# 导出Excel 1 //导出Excel 2 private void ExportExcel(string fileName, System.Data.DataTable myDGV, stri ...

  7. c++ class基础知识

    目录 class 创建对象 通过对象指针访问类成员 类方法可以定义在类体外部(要用到域解析符:. 类成员/类方法访问权限 构造函数 析构函数Destructor this指针 静态变量 静态函数 co ...

  8. Golang依赖管理工具: go module 详解

    Golang依赖管理工具: go module (go1.11+) 大多数语言都会有包管理工具,像Node有npm,PHP有composer,Java有Maven和Gradle. 可是,Go语言一直缺 ...

  9. git基础代码获取

    1.新建文件夹 2.使用命令git init 初始化 3.见你与远程厂库的连接,git remote add origin 远程仓库地址 4.将远程仓库代码拉去到本地,git fetch origin ...

  10. linux下yum安装时出现Loaded plugins: fastestmirror

    linux使用yum安装软件时出现报错Loaded plugins:fastestmirror,是提示这个插件不能使用了,fastestmirror是yum的一个加速插件, 解决的办法是:将这个插件禁 ...