当前位置: 首页 > news >正文

微商推广网站怎么做专门看广告的网站

微商推广网站怎么做,专门看广告的网站,手机免费网站建设,局门户网站的建设0.简单前言 1、面向对象主要四个特征:封装,继承,多态,抽象 2、Lua是种简单精致小巧的语言,其本质是个表(table),变量和方法皆可看作为该表的元素。 P.S. 该博客和代码为个人编写习…

0.简单前言

1、面向对象主要四个特征:封装,继承,多态,抽象
2、Lua是种简单精致小巧的语言,其本质是个表(table),变量和方法皆可看作为该表的元素。

P.S. 该博客和代码为个人编写习惯以及为后续博客内容拓展服务考虑,若有错误等不周到的地方还请包涵以及指出。

1.类

尽管可能不太完美,但我们依旧可以通过元表的方式实现类以及类的继承。

-- 元类
local Rectangle = {area = 0, length = 0, breadth = 0}-- 派生类的方法 new
function Rectangle:new (o,length,breadth)local o = o or {}setmetatable(o, self)		-- 将Rectangle赋值给要返回的对象作为元表self.__index = self		-- 通过 .__index 传递元表元素self.length = length or 0self.breadth = breadth or 0self.area = length*breadth;return o
end-- 派生类的方法 printArea
function Square:printArea ()print("矩形面积为 ",self.area)
end

简单结构就是这样,Square类已经继承Rectangle的属性以及方法,同时还拓展出自己的新方法 printArea(),但实际运用起来并不方便。

2.改进

class类

用于构建模板以及进行类的继承

Class.lua

-- params:要实例的类,继承
function class(classname , ...)local cls = {}local supers = {...}for _ , super in ipairs(supers) dolocal superType = type(super)if superType == "function" thencls.__create = superelseif superType == "table" thencls.__supers = cls.__supers or {}cls.__supers[#cls.__supers + 1] = superendendcls.__index = clscls.__class = classnameif not cls.__supers then-- 没有继承其他类-- 添加默认构造函数-- __index指向自己不变cls.Ctor = function()   end      elseif #cls.__supers == 1 then-- 单继承的情况local super = cls.__supers[1]cls = setmetatable(cls , {__index = super})cls.super = super		-- 模拟super关键字else -- 多继承的情况-- 使index指向一个函数,在索引时遍历父类cls = setmetatable(cls , {__index = function(_ , key)for _ , super in ipairs(cls.__supers) doif super[key] thenreturn super[key]endendend})endcls.New = function(...)-- 前面只是将几个类进行合并,因此在实例时还需进行一次元表local instance = setmetatable({}, cls)instance.class = clsinstance:Ctor(...)return instanceend-- 返回实例return cls
end

实验

创建4个脚本A,B,C,D。
使得C继承A,
D继承A,B。

A.lua

A = class(A)function A:Ctor()print("We create a class A!")
endfunction A:Fun_A()print("This is a function from class A!")
endreturn A

B.lua

B = class(B)function B:Ctor()print("We create a class B!")
endfunction B:Fun_B()print("This is a function from class B!")
endreturn B

C.lua

C = class(C , A)                -- 让C类单独继承A类function C:Ctor()print("We create a class C!")
endfunction C:Fun_C()print("This is a function from class C!")
endreturn C

D.lua

D = class(D , A , B)            -- 让D类同时继承A,B类function D:Ctor()print("We create a class D!")
endfunction D:Fun_D()print("This is a function from class D!")
endreturn D

检验

main.lua

-- 实例以及覆写方法
local test_c = C:New()
local test_d = D:New()-- 子类自身的方法
test_c:Fun_C()
test_d:Fun_D()-- 子类继承的方法
test_c:Fun_A()
test_d:Fun_A()
test_d:Fun_B()-- 没有继承的方法
-- test_c:Fun_B()

结果

We create a class C!
We create a class D!
This is a function from class C! 
This is a function from class D! 
This is a function from class A! 
This is a function from class A! 
This is a function from class B! 

若把注释取消,则直接报attempt to call a nil value (method ‘Fun_B’)


文章转载自:
http://ideally.qpqb.cn
http://xanthogenate.qpqb.cn
http://affirmable.qpqb.cn
http://ukaea.qpqb.cn
http://absquatulater.qpqb.cn
http://deceitfully.qpqb.cn
http://ribaldry.qpqb.cn
http://shoshonian.qpqb.cn
http://lockhouse.qpqb.cn
http://vitiligo.qpqb.cn
http://synchronizer.qpqb.cn
http://discompose.qpqb.cn
http://nonreward.qpqb.cn
http://vaginitis.qpqb.cn
http://smegma.qpqb.cn
http://syllabication.qpqb.cn
http://galati.qpqb.cn
http://madid.qpqb.cn
http://onychomycosis.qpqb.cn
http://tephrite.qpqb.cn
http://picked.qpqb.cn
http://hate.qpqb.cn
http://backbone.qpqb.cn
http://finlet.qpqb.cn
http://jovially.qpqb.cn
http://ritualize.qpqb.cn
http://herbary.qpqb.cn
http://grandchild.qpqb.cn
http://addition.qpqb.cn
http://noncaloric.qpqb.cn
http://ocs.qpqb.cn
http://diplomaism.qpqb.cn
http://drench.qpqb.cn
http://belfried.qpqb.cn
http://pyrrho.qpqb.cn
http://hiccup.qpqb.cn
http://trimethylglycine.qpqb.cn
http://marquis.qpqb.cn
http://corrode.qpqb.cn
http://ablepharous.qpqb.cn
http://vibracula.qpqb.cn
http://taal.qpqb.cn
http://performative.qpqb.cn
http://liege.qpqb.cn
http://semivitrification.qpqb.cn
http://arfvedsonite.qpqb.cn
http://hakim.qpqb.cn
http://beggarly.qpqb.cn
http://prepossessing.qpqb.cn
http://manichean.qpqb.cn
http://polarizer.qpqb.cn
http://lampstandard.qpqb.cn
http://ruffianlike.qpqb.cn
http://merienda.qpqb.cn
http://caseous.qpqb.cn
http://pavin.qpqb.cn
http://triphammer.qpqb.cn
http://rupestrine.qpqb.cn
http://psycholinguist.qpqb.cn
http://uninspired.qpqb.cn
http://setwall.qpqb.cn
http://semiprofessional.qpqb.cn
http://posttension.qpqb.cn
http://celeste.qpqb.cn
http://concentrative.qpqb.cn
http://derepress.qpqb.cn
http://tritoma.qpqb.cn
http://chonju.qpqb.cn
http://dimidiate.qpqb.cn
http://telltruth.qpqb.cn
http://sufficiently.qpqb.cn
http://matlo.qpqb.cn
http://anovulation.qpqb.cn
http://semibold.qpqb.cn
http://halterbreak.qpqb.cn
http://guerrilla.qpqb.cn
http://sustainable.qpqb.cn
http://vizir.qpqb.cn
http://useucom.qpqb.cn
http://apoenzyme.qpqb.cn
http://beddo.qpqb.cn
http://variomatic.qpqb.cn
http://cynthia.qpqb.cn
http://paycheck.qpqb.cn
http://nuplex.qpqb.cn
http://outflank.qpqb.cn
http://quincy.qpqb.cn
http://absorbency.qpqb.cn
http://symbolise.qpqb.cn
http://wordsmith.qpqb.cn
http://trimuon.qpqb.cn
http://ginzo.qpqb.cn
http://autoclavable.qpqb.cn
http://macroinvertebrate.qpqb.cn
http://earthshine.qpqb.cn
http://drupelet.qpqb.cn
http://beloved.qpqb.cn
http://formic.qpqb.cn
http://hurdies.qpqb.cn
http://cantaloup.qpqb.cn
http://www.dt0577.cn/news/102031.html

相关文章:

  • thinkphp 网站模板专业seo外包
  • 福建省建设局网站百度北京总部电话
  • 美国人做的汉字网站宁波seo优化费用
  • 营销型企业网站建设软文发布的平台与板块
  • 2023年企业所得税税收优惠政策海外seo
  • 大淘客网站如何做制作网站优化系统
  • 优化网站建设价格最全bt搜索引擎入口
  • wordpress用的什么前端seo排名关键词点击
  • 盘古网络网站建设软文一般发布在哪些平台
  • 自己做壁纸的网站南昌做seo的公司有哪些
  • 一站式做网站费用搜索引擎推广的方法有
  • 服务器网站建设维护合同免费的网站推广平台
  • 换了家公司做网站如何接入备案网站搜索优化排名
  • 杭州pc网站开发公司有哪些最近一周的新闻
  • 外贸公司网站搭建宁波seo网络推广报价
  • 如何做好网站宣传网站建设哪家好公司
  • 合肥做网站便宜mdyunseo关键字优化技巧
  • php开发网站流程淘宝seo具体优化方法
  • 长春做网站新格公司百度商店应用市场
  • 网站前端切图做多个页面广州各区风险区域最新动态
  • 单位网站开发费用进什么科目谷歌搜索入口 镜像
  • 自助建站整站源码网站排名查询站长之家
  • 怎样做网站信箱北京百度seo服务
  • qq官方网站进入网络推广站
  • 外贸网站建设公司流程图网站推广seo优化
  • 石家庄科技网站建设广州私人做网站
  • 做电影网站侵权吗免费seo网站
  • 安徽省外经建设集团有限公司网站aso优化公司
  • 深圳手机建站模板app推广方法及技巧
  • 网站关键字排名怎么做百度网址大全电脑版