首页 > 其他 > 详细

lua进阶7--- 面向对象

时间:2014-07-16 17:32:47      阅读:250      评论:0      收藏:0      [点我收藏+]

lua 里面的面向对象可以使开发看起来更简洁 

local tmp = {};
function tmp:create(id)
    local obj = {
      m_id = id,
	  m_name = "guoyilong ",	
	};
	setmetatable(obj, {__index = tmp});
	return obj;
end 

function tmp:printout()
	self.m_id = self.m_id * 45;
	print("===========> self.m_id ",self.m_id);
end


local tt = tmp:create(45);
print("=====> ",tt.m_id);
tt:printout();


obj 作为类tmp 的属性


lua进阶7--- 面向对象,布布扣,bubuko.com

lua进阶7--- 面向对象

原文:http://blog.csdn.net/guoyilongedu/article/details/37818701

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!