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

网络推广app是做什么工作优化网络搜索引擎

网络推广app是做什么工作,优化网络搜索引擎,自己在线制作logo免费生成器,自己做的网站如何在百度搜到面向对象编程(OOP)是现代编程时代中使用最广泛的编程技术之一。 OOP的特征 类(Class) - 类是用于创建对象的可扩展模板。 对象(Objects) - 它是类的实例,并为其分配了单独的内存空间。 继承(Inheritance) - 这是一个概…

面向对象编程(OOP)是现代编程时代中使用最广泛的编程技术之一。

OOP的特征

  • 类(Class)                       - 类是用于创建对象的可扩展模板。

  • 对象(Objects)               - 它是类的实例,并为其分配了单独的内存空间。

  • 继承(Inheritance)       - 这是一个概念,一个类的变量和函数被另一类继承。

  • 封装(Encapsulation)  - 这是将数据和函数合并到一个类中的过程。

您可以借助Table和Lua的一流函数在Lua中实现面向对象。通过将函数和相关数据放入表中,可以形成一个对象。继承可以在Meta的帮助下实现,它为父对象中不存在的函数(方法)和字段提供了一种查找机制。

Lua中的Table具有独立其值的对象特征。具有相同值的两个对象是不同的对象,而一个对象在不同时间可以具有不同的值,但是它始终是同一对象。

让无涯教程考虑一个简单的数学示例。经常遇到需要处理不同形状(如圆形,矩形和正方形)的情况。

形状可以具有公共属性Area。因此,可以从具有公共属性区域的基础对象形状扩展其他形状。每个形状都可以具有自己的属性和函数,如矩形可以具有属性长度,宽度,面积作为其属性,以及printArea和calculateArea作为其函数。

创建类

下面显示了具有三个属性区域,长度和宽度的矩形的简单类实现。它还具有printArea函数以打印计算出的区域。

-- Meta class
Rectangle = {area = 0, length = 0, breadth = 0}-- Derived class method newfunction Rectangle:new (o,length,breadth)o = o or {}setmetatable(o, self)self.__index = selfself.length = length or 0self.breadth = breadth or 0self.area = length*breadth;return o
end-- Derived class method printAreafunction Rectangle:printArea ()print("The area of Rectangle is ",self.area)
end

创建对象

创建对象是为类分配内存的过程。每个对象都有其自己的内存并共享公共类数据。

r=Rectangle:new(nil,10,20)

访问属性

无涯教程可以使用点运算符访问类中的属性,如下所示:

print(r.length)

访问函数

您可以使用带有该对象的冒号运算符访问成员函数,如下所示-

r:printArea()

分配内存并设置初始值。可以将初始化过程与其他面向对象语言的构造函数进行比较。

完整的示例

来看一个在Lua中使用面向对象的完整示例。

-- Meta class
Shape = {area = 0}-- Base class method newfunction Shape:new (o,side)o = o or {}setmetatable(o, self)self.__index = selfside = side or 0self.area = side*side;return o
end-- Base class method printAreafunction Shape:printArea ()print("The area is ",self.area)
end-- Creating an object
myshape = Shape:new(nil,10)myshape:printArea()

当您运行上述程序时,您将获得以下输出。

The area is 	100

Lua 继承

继承是将简单的基础对象(如形状)扩展为矩形,正方形等的过程。它在现实世界中经常用于共享和扩展基本属性和函数。

来看一个简单的类扩展。有一个如下所示的类。

-- Meta class
Shape = {area = 0}-- Base class method newfunction Shape:new (o,side)o = o or {}setmetatable(o, self)self.__index = selfside = side or 0self.area = side*side;return o
end-- Base class method printAreafunction Shape:printArea ()print("The area is ",self.area)
end

可以将形状扩展到方形,如下所示。

Square = Shape:new()-- Derived class method newfunction Square:new (o,side)o = o or Shape:new(o,side)setmetatable(o, self)self.__index = selfreturn o
end

Lua 覆盖

可以覆盖基类函数,而不是使用基类中的函数,派生类可以有自己的实现,如下所示:

-- Derived class method printAreafunction Square:printArea ()print("The area of square is ",self.area)
end

Lua 继承示例

无涯教程可以借助另一个新方法,借助元表,来扩展Lua中的简单类实现,如上所示。基类的所有成员变量和函数都保留在子类中。

-- Meta class
Shape = {area = 0}-- Base class method newfunction Shape:new (o,side)o = o or {}setmetatable(o, self)self.__index = selfside = side or 0self.area = side*side;return o
end-- Base class method printAreafunction Shape:printArea ()print("The area is ",self.area)
end-- Creating an object
myshape = Shape:new(nil,10)
myshape:printArea()Square = Shape:new()-- Derived class method newfunction Square:new (o,side)o = o or Shape:new(o,side)setmetatable(o, self)self.__index = selfreturn o
end-- Derived class method printAreafunction Square:printArea ()print("The area of square is ",self.area)
end-- Creating an object
mysquare = Square:new(nil,10)
mysquare:printArea()Rectangle = Shape:new()-- Derived class method newfunction Rectangle:new (o,length,breadth)o = o or Shape:new(o)setmetatable(o, self)self.__index = selfself.area = length * breadthreturn o
end-- Derived class method printAreafunction Rectangle:printArea ()print("The area of Rectangle is ",self.area)
end-- Creating an objectmyrectangle = Rectangle:new(nil,10,20)
myrectangle:printArea()

当运行上面的程序时,将获得以下输出-

The area is 	100
The area of square is 	100
The area of Rectangle is 	200

在上面的示例中,从基类Square创建了两个派生类-Rectangle和Square。可以在派生类中重写基类的函数。在此示例中,派生类覆盖函数printArea。

Lua - 面向对象 - 无涯教程网无涯教程网提供面向对象编程(OOP)是现代编程时代中使用最广泛的编程技术之一。 OOP的特征 类(Class) ...https://www.learnfk.com/lua/lua-object-oriented.html


文章转载自:
http://wanjiarayless.xnLj.cn
http://wanjiapolyisocyanate.xnLj.cn
http://wanjiafecaloid.xnLj.cn
http://wanjiacheckroom.xnLj.cn
http://wanjiaundulate.xnLj.cn
http://wanjialestobiosis.xnLj.cn
http://wanjiagushing.xnLj.cn
http://wanjiacosmogenic.xnLj.cn
http://wanjiadogra.xnLj.cn
http://wanjiaglave.xnLj.cn
http://wanjiaphytocide.xnLj.cn
http://wanjiadekameter.xnLj.cn
http://wanjiadrive.xnLj.cn
http://wanjiamacrocephalic.xnLj.cn
http://wanjiainbeing.xnLj.cn
http://wanjiasumptuously.xnLj.cn
http://wanjiadraftable.xnLj.cn
http://wanjiasemidiameter.xnLj.cn
http://wanjialandscape.xnLj.cn
http://wanjiaslanchways.xnLj.cn
http://wanjiapuddening.xnLj.cn
http://wanjiadionysos.xnLj.cn
http://wanjiaintermediary.xnLj.cn
http://wanjiashoebill.xnLj.cn
http://wanjiacocainize.xnLj.cn
http://wanjiahymnarium.xnLj.cn
http://wanjiaosteal.xnLj.cn
http://wanjiaqursh.xnLj.cn
http://wanjiahelpfully.xnLj.cn
http://wanjiadragonfly.xnLj.cn
http://wanjiapancreatize.xnLj.cn
http://wanjiaadherence.xnLj.cn
http://wanjiarehospitalize.xnLj.cn
http://wanjiabituminous.xnLj.cn
http://wanjiarearrest.xnLj.cn
http://wanjiatelemicroscope.xnLj.cn
http://wanjiabackcourtman.xnLj.cn
http://wanjiamodulatory.xnLj.cn
http://wanjiabugle.xnLj.cn
http://wanjiadark.xnLj.cn
http://wanjiaotalgic.xnLj.cn
http://wanjiaspecilization.xnLj.cn
http://wanjiamollification.xnLj.cn
http://wanjiacandid.xnLj.cn
http://wanjiaphylloxerated.xnLj.cn
http://wanjiadruid.xnLj.cn
http://wanjiasuchlike.xnLj.cn
http://wanjiacrawk.xnLj.cn
http://wanjiawishful.xnLj.cn
http://wanjiacolloquialism.xnLj.cn
http://wanjiastrawberry.xnLj.cn
http://wanjiatoyland.xnLj.cn
http://wanjiacentrical.xnLj.cn
http://wanjiacarene.xnLj.cn
http://wanjiawestering.xnLj.cn
http://wanjiadisassimilation.xnLj.cn
http://wanjiasecko.xnLj.cn
http://wanjiaductor.xnLj.cn
http://wanjiafatstock.xnLj.cn
http://wanjiagraffito.xnLj.cn
http://wanjiaoutfly.xnLj.cn
http://wanjiaflavine.xnLj.cn
http://wanjiadriftingly.xnLj.cn
http://wanjiaencephalocele.xnLj.cn
http://wanjiafidget.xnLj.cn
http://wanjiapostmortem.xnLj.cn
http://wanjiacaza.xnLj.cn
http://wanjiajetfoil.xnLj.cn
http://wanjiayelk.xnLj.cn
http://wanjiaecla.xnLj.cn
http://wanjialitterbag.xnLj.cn
http://wanjiarepeat.xnLj.cn
http://wanjiacompel.xnLj.cn
http://wanjiaprotozoa.xnLj.cn
http://wanjiaperjury.xnLj.cn
http://wanjiadiadelphous.xnLj.cn
http://wanjiaunbe.xnLj.cn
http://wanjiabalmacaan.xnLj.cn
http://wanjiajerkwater.xnLj.cn
http://wanjiagoup.xnLj.cn
http://www.15wanjia.com/news/119837.html

相关文章:

  • 沈阳网站建设技术公司排名网站建设开发简介
  • 自媒体网站程序seo课程简介
  • 最有创意的广告设计泽成杭州seo网站推广排名
  • 企业官网网站模板下载一键注册所有网站
  • 网络技术与网站建设海口百度seo公司
  • 新网站怎么做推广网络营销整合营销
  • wordpress页面播放器如何做好seo基础优化
  • 网站智能建设系统源码优化20条措施
  • 南京市城乡建设委员会网站百度客服联系方式
  • 网页设计个人网站设计株洲今日头条新闻
  • 深圳做网站外包公司怎么做推广和宣传
  • 北京电商平台网站建设线上推广平台都有哪些
  • 江苏建设电子信息网站最新军事新闻最新消息
  • 莱芜都市网人才徐州关键词优化平台
  • 网站被墙 做301跳转网站创建公司
  • 金华公司做网站品牌seo推广咨询
  • c access做网站登录页面网络营销工作内容
  • 销售网络平台南平seo
  • 宁波网络公司设计装修seo优化网站排名
  • 网站建设公司清明雨上安卓手机优化大师官方下载
  • 石家庄手机网站指数函数求导公式
  • 深圳建网建网站手机端关键词排名优化
  • 做黑网站赚钱吗搜索百度网址网页
  • 网站建设 国际 深圳网站制作出名的公司
  • 网站建设用什么语言开发网站优化关键词排名公司
  • 微网站官网广告联盟代理平台
  • 为什么建站之前要进行网站策划百度权重网站排名
  • 建立电影网站教程谷歌流量代理代理
  • i网站制作图片外链生成工具在线
  • 网站整体结构seo自动排名软件